Skip to content

Commit 3781a0d

Browse files
committed
ImageAI v2.0.3, Transfer learning, Continous Learning, Multi-recognition, Tensorflow conversion, Video detection timeout and bug fixes.
1 parent afc6307 commit 3781a0d

File tree

165 files changed

+12788
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+12788
-549
lines changed

.idea/ImageAI.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 674 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
1-
# ImageAI <br>
1+
# ImageAI (v 2.0.3)<br>
22
A python library built to empower developers to build applications and systems with self-contained Deep Learning and Computer Vision capabilities using simple
33
and few lines of code. <br><br>
44

55
<img src="logo1.png" style="width: 500px; height: auto; margin-left: 50px; " /> <br>
66

7-
An <b>AI Commons</b> project <a href="https://aicommons.science" >https://aicommons.science </a>
8-
Developed and Maintained by [Moses Olafenwa](https://twitter.com/OlafenwaMoses) and [John Olafenwa](https://twitter.com/johnolafenwa), brothers, creators of [TorchFusion](https://github.com/johnolafenwa/TorchFusion)
9-
and Authors of [Introduction to Deep Computer Vision](https://john.aicommons.science/deepvision)
7+
An <b>DeepQuest AI</b> project <a href="https://deepquestai.com" >https://deepquestai.com </a>.
8+
Developed and Maintained by [Moses Olafenwa](https://twitter.com/OlafenwaMoses) and [John Olafenwa](https://twitter.com/johnolafenwa), brothers, creators of [TorchFusion](https://github.com/johnolafenwa/TorchFusion), Authors of [Introduction to Deep Computer Vision](https://john.aicommons.science/deepvision) and creators of [DeepStack AI Server](https://deepstack.cc).
109
<hr>
1110

1211
Built with simplicity in mind, <b>ImageAI</b>
1312
supports a list of state-of-the-art Machine Learning algorithms for image prediction, custom image prediction, object detection, video detection, video object tracking
1413
and image predictions trainings. <b>ImageAI</b> currently supports image prediction and training using 4 different Machine Learning algorithms
15-
trained on the ImageNet-1000 dataset. <b>ImageAI</b> also supports object detection, video detection and object tracking using RetinaNet, YOLOv3 and TinyYOLOv3 trained on COCO dataset. <br>
14+
trained on the ImageNet-1000 dataset. <b>ImageAI</b> also supports object detection, video detection and object tracking using RetinaNet, YOLOv3 and TinyYOLOv3 trained on COCO dataset. Finally, <b>ImageAI</b> allows you to train custom models for your peforming recognition of new objects. <br>
1615
Eventually, <b>ImageAI</b> will provide support for a wider
1716
and more specialized aspects of Computer Vision including and not limited to image
1817
recognition in special environments and special fields.
1918

20-
<br> <br>
19+
<br>
2120

22-
<b>New Release : ImageAI 2.0.2</b>
21+
<b>New Release : ImageAI 2.0.3</b>
2322
<br> What's new:
2423
<br>
25-
- Option to state image size during custom image prediction model trainings <br>
26-
- Object Detection and Video Object detection now returns bounding box coordinates **('box points')** (x1,y1,x2, y2) for each object detected in addition to object's 'name' and 'percentage probability' <br>
27-
- Options to hide 'percentage probability' and/or object 'name' from being shown in detected image or video
28-
- Support for video object detection on video live stream from device camera, connected camera and IP camera <br>
29-
- Support for **YOLOv3** and **TinyYOLOv3** for all object detection and video object detection tasks.
30-
- Video object detection for all input types (video file and camera) now allows defining custom functions to execute after each frame, each second and each minute of the video is detected and processed. Also include option to specify custom function at once video is fully detected and processed <br>
31-
- For each custom function specified, **ImageAI** returns the **frame**/**seconds**/**minute**/**full video analysis** of the detections that include the objects' details ( **name** , **percentage** **probability**, **box_points**), number of instance of each unique object detected (counts) and overall average count of the number of instance of each unique object detected in the case of **second** / **minute** / **full video analysis**<br>
32-
- Options to return detected frame at every frame, second or minute processed as a **Numpy array**.
24+
- Options to set video <a href="imageai/Detection/VIDEO.md#detectiontimeout"><b>detection timeout</b></a> in seconds <br>
25+
- Options to save trained <a href="imageai/Prediction/CUSTOMTRAINING.md#savefullmodel">custom model in full </a><br>
26+
- Support for running custom <a href="imageai/Prediction/CUSTOMPREDICTION.md#custompredictionfullmodel">prediction with fully saved model</a> without specifying network type <br>
27+
- Support for running custom prediction with any <a href="imageai/Prediction/CUSTOMPREDICTION.md#custompredictionfullmodel">fully saved <b>Keras</b> model </a><br>
28+
- Support for converting custom trained models to <a href="imageai/Prediction/CUSTOMPREDICTION.md#converttensorflow">Tensorflow (<b>.pb</b>) format </a> <br>
29+
- Support for <a href="imageai/Prediction/CUSTOMPREDICTION.md#continuoustraining"><b>continuous training</b></a> from previously saved custom model <br>
30+
- Support for <a href="imageai/Prediction/CUSTOMTRAINING.md#transferlearning"><b>transfer learning</b></a> from pre-trained models for small datasets<br>
31+
- Only <a href="imageai/Prediction/CUSTOMTRAINING.md">models with increased accuracy</a> will be saved during training <br>
32+
- Support for loading and prediction with <a href="imageai/Prediction/CUSTOMPREDICTION.md#custompredictionmultiple">multiple custom models</a> <br>
33+
- Support for <a href="imageai/Prediction/CUSTOMPREDICTION.md#convertdeepstack">exporting models</a> to <b>DeepStack format</b> <br>
34+
35+
3336
<br> <br>
3437
<br>
3538

3639
<h3><b><u>TABLE OF CONTENTS</u></b></h3>
37-
<a href="#dependencies" >&#9635 Dependencies</a><br>
38-
<a href="#installation" >&#9635 Installation</a><br>
39-
<a href="#prediction" >&#9635 Image Prediction</a><br>
40-
<a href="#detection" >&#9635 Object Detection</a><br>
41-
<a href="#videodetection" >&#9635 Video Object Detection, Tracking & Analysis</a><br>
42-
<a href="#customtraining" >&#9635 Custom Model Training</a><br>
43-
<a href="#customprediction" >&#9635 Custom Image Prediction</a><br>
44-
<a href="#documentation" >&#9635 Documentation</a><br>
45-
<a href="#sample" >&#9635 Projects Built on ImageAI</a><br>
40+
<a href="#dependencies" > &#9635 Dependencies</a><br>
41+
<a href="#installation" > &#9635 Installation</a><br>
42+
<a href="#prediction" > &#9635 Image Prediction</a><br>
43+
<a href="#detection" > &#9635 Object Detection</a><br>
44+
<a href="#videodetection" > &#9635 Video Object Detection, Tracking & Analysis</a><br>
45+
<a href="#customtraining" >&#9635 Custom Model Training</a><br>
46+
<a href="#customprediction" > &#9635 Custom Image Prediction</a><br>
47+
<a href="#documentation" > &#9635 Documentation</a><br>
48+
<a href="#sample" > &#9635 Projects Built on ImageAI</a><br>
49+
<a href="#real-time-and-high-performance-implementation" >&#9635 High Performance Implementation</a><br>
4650
<a href="#recommendation" >&#9635 AI Practice Recommendations</a><br>
4751
<a href="#contact" >&#9635 Contact Developers</a><br>
4852
<a href="#contributors" >&#9635 Contributors</a><br>
@@ -60,12 +64,9 @@ Built with simplicity in mind, <b>ImageAI</b>
6064
<span><b>- Python 3.5.1 (and later versions) </b> <a href="https://www.python.org/downloads/" style="text-decoration: none;" >Download</a> (Support for Python 2.7 coming soon) </span> <br>
6165
<span><b>- pip3 </b> <a href="https://pypi.python.org/pypi/pip" style="text-decoration: none;" >Install</a></span> <br>
6266
<span><b>- Tensorflow 1.4.0 (and later versions) </b> <a href="https://www.tensorflow.org/install/install_windows" style="text-decoration: none;" > Install</a></span> or install via pip <pre> pip3 install --upgrade tensorflow </pre>
63-
<span><b>- Numpy 1.13.1 (and later versions) </b> <a href="https://www.scipy.org/install.html" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install numpy </pre>
64-
<span><b>- SciPy 0.19.1 (and later versions) </b> <a href="https://www.scipy.org/install.html" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install scipy </pre>
67+
6568
<span><b>- OpenCV </b> <a href="https://pypi.python.org/pypi/opencv-python" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install opencv-python </pre>
66-
<span><b>- Pillow </b> <a href="https://pypi.org/project/Pillow/2.2.1/" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install pillow </pre>
67-
<span><b>- Matplotlib </b> <a href="https://matplotlib.org/users/installing.html" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install matplotlib </pre>
68-
<span><b>- h5py </b> <a href="http://docs.h5py.org/en/latest/build.html" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install h5py </pre>
69+
6970
<span><b>- Keras 2.x </b> <a href="https://keras.io/#installation" style="text-decoration: none;" >Install</a></span> or install via pip <pre> pip3 install keras </pre>
7071

7172
<div id="installation"></div>
@@ -251,7 +252,7 @@ FOR UBUNTU <br>
251252
<br><br>
252253

253254
<div id="sample"></div>
254-
<h3><b><u>Sample Applications</u></b></h3> As a demonstration of what you can do with ImageAI, we have
255+
<h3><b><u>Projects Built on ImageAI</u></b></h3> As a demonstration of what you can do with ImageAI, we have
255256
built a complete AI powered Photo gallery for Windows called <b>IntelliP</b> , using <b>ImageAI</b> and UI framework <b>Kivy</b>. Follow this
256257
<a href="https://github.com/OlafenwaMoses/IntelliP" > link </a> to download page of the application and its source code. <br> <br>
257258

Thumbs.db

-58.5 KB
Binary file not shown.

build/lib/imageai/Detection/YOLOv3/__init__.py

Whitespace-only changes.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
from functools import wraps
2+
3+
import numpy as np
4+
import tensorflow as tf
5+
from keras import backend as K
6+
from keras.layers import Conv2D, MaxPool2D, Add, ZeroPadding2D, UpSampling2D, Concatenate
7+
from keras.layers.advanced_activations import LeakyReLU
8+
from keras.layers.normalization import BatchNormalization
9+
from keras.regularizers import l2
10+
from keras.models import Model, Input
11+
12+
13+
14+
def NetworkConv2D_BN_Leaky(input, channels, kernel_size, kernel_regularizer = l2(5e-4), strides=(1,1), padding="same", use_bias=False):
15+
16+
network = Conv2D( filters=channels, kernel_size=kernel_size, strides=strides, padding=padding, kernel_regularizer=kernel_regularizer, use_bias=use_bias)(input)
17+
network = BatchNormalization()(network)
18+
network = LeakyReLU(alpha=0.1)(network)
19+
return network
20+
21+
def residual_block(input, channels, num_blocks):
22+
network = ZeroPadding2D(((1,0), (1,0)))(input)
23+
network = NetworkConv2D_BN_Leaky(input=network,channels=channels, kernel_size=(3,3), strides=(2,2), padding="valid")
24+
25+
for blocks in range(num_blocks):
26+
network_1 = NetworkConv2D_BN_Leaky(input=network, channels= channels // 2, kernel_size=(1,1))
27+
network_1 = NetworkConv2D_BN_Leaky(input=network_1,channels= channels, kernel_size=(3,3))
28+
29+
network = Add()([network, network_1])
30+
return network
31+
32+
def darknet(input):
33+
network = NetworkConv2D_BN_Leaky(input=input, channels=32, kernel_size=(3,3))
34+
network = residual_block(input=network, channels=64, num_blocks=1)
35+
network = residual_block(input=network, channels=128, num_blocks=2)
36+
network = residual_block(input=network, channels=256, num_blocks=8)
37+
network = residual_block(input=network, channels=512, num_blocks=8)
38+
network = residual_block(input=network, channels=1024, num_blocks=4)
39+
40+
41+
return network
42+
43+
def last_layers(input, channels_in, channels_out, layer_name=""):
44+
45+
46+
47+
network = NetworkConv2D_BN_Leaky( input=input, channels=channels_in, kernel_size=(1,1))
48+
network = NetworkConv2D_BN_Leaky(input=network, channels= (channels_in * 2) , kernel_size=(3, 3))
49+
network = NetworkConv2D_BN_Leaky(input=network, channels=channels_in, kernel_size=(1, 1))
50+
network = NetworkConv2D_BN_Leaky(input=network, channels=(channels_in * 2), kernel_size=(3, 3))
51+
network = NetworkConv2D_BN_Leaky(input=network, channels=channels_in, kernel_size=(1, 1))
52+
53+
network_1 = NetworkConv2D_BN_Leaky(input=network, channels=(channels_in * 2), kernel_size=(3, 3))
54+
network_1 = Conv2D(filters=channels_out, kernel_size=(1,1), name=layer_name)(network_1)
55+
56+
return network, network_1
57+
58+
def yolo_main(input, num_anchors, num_classes):
59+
60+
darknet_network = Model(input, darknet(input))
61+
62+
network, network_1 = last_layers(darknet_network.output, 512, num_anchors * (num_classes + 5), layer_name="last1")
63+
64+
network = NetworkConv2D_BN_Leaky( input=network, channels=256, kernel_size=(1,1))
65+
network = UpSampling2D(2)(network)
66+
network = Concatenate()([network, darknet_network.layers[152].output])
67+
68+
network, network_2 = last_layers(network, 256, num_anchors * (num_classes + 5), layer_name="last2")
69+
70+
network = NetworkConv2D_BN_Leaky(input=network, channels=128, kernel_size=(1, 1))
71+
network = UpSampling2D(2)(network)
72+
network = Concatenate()([network, darknet_network.layers[92].output])
73+
74+
network, network_3 = last_layers(network, 128, num_anchors * (num_classes + 5), layer_name="last3")
75+
76+
return Model(input, [network_1, network_2, network_3])
77+
78+
79+
def tiny_yolo_main(input, num_anchors, num_classes):
80+
network_1 = NetworkConv2D_BN_Leaky(input=input, channels=16, kernel_size=(3,3) )
81+
network_1 = MaxPool2D(pool_size=(2,2), strides=(2,2), padding="same")(network_1)
82+
network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=32, kernel_size=(3, 3))
83+
network_1 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)
84+
network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=64, kernel_size=(3, 3))
85+
network_1 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)
86+
network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=128, kernel_size=(3, 3))
87+
network_1 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)
88+
network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=256, kernel_size=(3, 3))
89+
90+
network_2 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)
91+
network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=512, kernel_size=(3, 3))
92+
network_2 = MaxPool2D(pool_size=(2, 2), strides=(1, 1), padding="same")(network_2)
93+
network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=1024, kernel_size=(3, 3))
94+
network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=256, kernel_size=(1, 1))
95+
96+
network_3 = NetworkConv2D_BN_Leaky(input=network_2, channels=512, kernel_size=(3, 3))
97+
network_3 = Conv2D(num_anchors * (num_classes + 5), kernel_size=(1,1))(network_3)
98+
99+
network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=128, kernel_size=(1, 1))
100+
network_2 = UpSampling2D(2)(network_2)
101+
102+
network_4 = Concatenate()([network_2, network_1])
103+
network_4 = NetworkConv2D_BN_Leaky(input=network_4, channels=256, kernel_size=(3, 3))
104+
network_4 = Conv2D(num_anchors * (num_classes + 5), kernel_size=(1,1))(network_4)
105+
106+
return Model(input, [network_3, network_4])

0 commit comments

Comments
 (0)