Skip to content

Commit c4baba9

Browse files
Merge pull request #618 from OlafenwaMoses/tensorflow2.0-port
Updated for Tensorflow 2.4.0
2 parents 1262edc + 94a2d22 commit c4baba9

File tree

163 files changed

+6427
-9015
lines changed

Some content is hidden

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

163 files changed

+6427
-9015
lines changed

.gitignore

+12-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ nosetests.xml
3535
coverage.xml
3636
*.cover
3737
.hypothesis/
38-
*.egg-info
38+
*.egg-info
39+
40+
# VSCode files
41+
.vscode/*
42+
!.vscode/settings.json
43+
!.vscode/tasks.json
44+
!.vscode/launch.json
45+
!.vscode/extensions.json
46+
*.code-workspace
47+
48+
# Local History for Visual Studio Code
49+
.history/

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dist: xenial
22
sudo: required
33
language: python
44
python:
5-
- '3.5'
5+
- '3.7.6'
66
install:
77
- pip install -r requirements.txt
88
- pip install pytest
@@ -14,12 +14,12 @@ script:
1414
- mkdir data-temp
1515
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/DenseNet-BC-121-32.h5
1616
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/inception_v3_weights_tf_dim_ordering_tf_kernels.h5
17-
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_weights_tf_dim_ordering_tf_kernels.h5
18-
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/squeezenet_weights_tf_dim_ordering_tf_kernels.h5
17+
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/resnet50_imagenet_tf.2.0.h5
18+
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/mobilenet_v2.h5
1919
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_densenet-0.763500.h5
2020
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_full_resnet_ex-001_acc-0.119792.h5
21-
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_resnet.h5
22-
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5
21+
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/idenprof_resnet_ex-056_acc-0.993062.h5
22+
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/resnet50_coco_best_v2.1.0.h5
2323
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo.h5
2424
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo-tiny.h5
2525
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essential-v4/pretrained-yolov3.h5

README.md

+42-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# ImageAI (v2.1.5)
1+
# ImageAI (v2.1.6)
22

3-
![Discourse status](https://img.shields.io/discourse/https/forum.imageai.org/status) [![Build Status](https://travis-ci.com/OlafenwaMoses/ImageAI.svg?branch=master)](https://travis-ci.com/OlafenwaMoses/ImageAI) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/OlafenwaMoses/ImageAI/blob/master/LICENSE) [![PyPI version](https://badge.fury.io/py/imageai.svg)](https://badge.fury.io/py/imageai) [![Downloads](https://pepy.tech/badge/imageai/month)](https://pepy.tech/project/imageai/month) [![Downloads](https://pepy.tech/badge/imageai/week)](https://pepy.tech/project/imageai/week) [![codecov](https://codecov.io/gh/TechnionYP5777/project-name/branch/master/graph/badge.svg)](https://codecov.io/gh/OlafenwaMoses/ImageAI)
3+
4+
5+
[![Build Status](https://travis-ci.com/OlafenwaMoses/ImageAI.svg?branch=master)](https://travis-ci.com/OlafenwaMoses/ImageAI) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/OlafenwaMoses/ImageAI/blob/master/LICENSE) [![PyPI version](https://badge.fury.io/py/imageai.svg)](https://badge.fury.io/py/imageai) [![Downloads](https://pepy.tech/badge/imageai/month)](https://pepy.tech/project/imageai) [![Downloads](https://pepy.tech/badge/imageai/week)](https://pepy.tech/project/imageai)
46

57
An open-source python library built to empower developers to build applications and systems with self-contained Deep Learning and Computer Vision capabilities using simple
68
and few lines of code.
@@ -9,7 +11,9 @@ An open-source python library built to empower developers to build applications
911

1012
<span class="badge-patreon"><a href="https://patreon.com/OlafenwaMoses" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
1113

12-
[ Click here](#sponsors) to see all [sponsors](#sponsors) for the **ImageAI** project!
14+
## ---------------------------------------------------
15+
## ImageAI will switch to PyTorch backend starting from June, 2021.
16+
## ---------------------------------------------------
1317

1418
![](logo1.png)
1519

@@ -29,16 +33,18 @@ Eventually, **ImageAI** will provide support for a wider
2933
recognition in special environments and special fields.
3034

3135

32-
**New Release : ImageAI 2.1.5**
36+
**New Release : ImageAI 2.1.6**
3337

3438
What's new:
3539

36-
- **Tensorboard** logging for all prediction and detection model training.
37-
- **Progress bar** for detection training
38-
- Allow prediction and detection in multi-threaded code
39-
- Automatic **Multi-GPU** utilization for detection training
40-
- Custom detection model **metrics** retrieval
41-
- Bug fix: change custom model probability from **string to float**
40+
- **Support Tensorflow 2.4.0**
41+
- **SqueezeNet replaced with MobileNetV2**
42+
- **Added TF 2.x compatible pre-trained models for ResNet recognition and RetinaNet detection**
43+
- **Deprecates '.predictImage()' function for '.classifyImage()'**
44+
- **Renames Model types as below:**
45+
- ResNet >> ResNet50
46+
- DenseNet >> DenseNet121
47+
-
4248

4349

4450
### TABLE OF CONTENTS
@@ -70,13 +76,26 @@ What's new:
7076
To use **ImageAI** in your application developments, you must have installed the following
7177
dependencies before you install **ImageAI** :
7278

73-
- Python 3.5.1 (and later versions)
74-
- Tensorflow 1.4.0 (and later versions) **(Tensorflow 2.0 coming soon)**
79+
- Python 3.7.6
80+
- Tensorflow 2.4.0
7581
- OpenCV
76-
- Keras 2.x
77-
78-
```bash
79-
pip install -U tensorflow keras opencv-python
82+
- Keras 2.4.3
83+
84+
You can install all the dependencies by running the commands below
85+
86+
**Tensorflow**
87+
```bash
88+
pip install tensorflow==2.4.0
89+
```
90+
91+
or **Tensorflow GPU** if you have NVIDIA GPU with CUDA and cuDNN installed.
92+
```bash
93+
pip install tensorflow-gpu==2.4.0
94+
```
95+
96+
**Other Dependencies**
97+
```bash
98+
pip install keras==2.4.3 numpy==1.19.3 pillow==7.0.0 scipy==1.4.1 h5py==2.10.0 matplotlib==3.3.2 opencv-python keras-resnet==0.2.0
8099
```
81100

82101
### Installation
@@ -85,7 +104,7 @@ pip install -U tensorflow keras opencv-python
85104
To install ImageAI, run the python installation instruction below in the command line:
86105

87106
```bash
88-
pip3 install imageai --upgrade
107+
pip install imageai --upgrade
89108
```
90109

91110
### Image Prediction
@@ -102,11 +121,11 @@ minivan : 1.7487050965428352
102121
```
103122

104123
**ImageAI** provides 4 different algorithms and model types to perform image prediction, trained on the ImageNet-1000 dataset.
105-
The 4 algorithms provided for image prediction include **SqueezeNet**, **ResNet**, **InceptionV3** and **DenseNet**.
124+
The 4 algorithms provided for image prediction include **MobileNetV2**, **ResNet50**, **InceptionV3** and **DenseNet121**.
106125

107126
Click the link below to see the full sample codes, explanations and best practices guide.
108127

109-
[>>> Tutorial & Guide](imageai/Prediction/README.md)
128+
[>>> Tutorial & Guide](imageai/Classification/README.md)
110129

111130

112131
### Object Detection
@@ -179,7 +198,7 @@ _A sample from the IdenProf Dataset used to train a Model for predicting profess
179198
You can train your custom models using SqueezeNet, ResNet50, InceptionV3 and DenseNet in **5** lines of code.
180199
Click the link below to see the guide to preparing training images, sample training codes, explanations and best practices.
181200

182-
[>>> Tutorials & Documentation](imageai/Prediction/CUSTOMTRAINING.md)
201+
[>>> Tutorials & Documentation](imageai/Classification/CUSTOMTRAINING.md)
183202

184203

185204
### Custom Image Prediction
@@ -202,7 +221,7 @@ You can use your custom models trained with SqueezeNet, ResNet50, InceptionV3 an
202221
Click the link below to see the guide to sample training codes, explanations, and best practices guide.
203222

204223

205-
[>>> Tutorials & Documentation](imageai/Prediction/CUSTOMPREDICTION.md)
224+
[>>> Tutorials & Documentation](imageai/Classification/CUSTOMCLASSIFICATION.md)
206225

207226

208227

@@ -360,12 +379,6 @@ You can cite **ImageAI** in your projects and research papers via the **BibTeX**
360379
```
361380

362381

363-
<div id="sponsors"></div>
364-
365-
### >>> Basic Sponsors
366-
367-
[<img src="https://avatars1.githubusercontent.com/u/46119184?s=460&v=" alt="David Lopez" style="width:50px;"/>](https://github.com/daviddbarrero)
368-
369382

370383
### References
371384
<div id="ref"></div>
@@ -398,3 +411,5 @@ You can cite **ImageAI** in your projects and research papers via the **BibTeX**
398411
[https://arxiv.org/abs/1804.02767](https://arxiv.org/abs/1804.02767)
399412
14. Experiencor, Training and Detecting Objects with YOLO3
400413
[https://github.com/experiencor/keras-yolo3](https://github.com/experiencor/keras-yolo3)
414+
15. MobileNetV2: Inverted Residuals and Linear Bottlenecks
415+
[https://arxiv.org/abs/1801.04381](https://arxiv.org/abs/1801.04381)

examples/custom_full_model_prediction.py

-18
This file was deleted.
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from imageai.Prediction.Custom import ModelTraining
1+
from imageai.Classification.Custom import ClassificationModelTrainer
22
import os
33

4-
trainer = ModelTraining()
5-
trainer.setModelTypeAsDenseNet()
4+
trainer = ClassificationModelTrainer()
5+
trainer.setModelTypeAsDenseNet121()
66
trainer.setDataDirectory("idenprof")
77
trainer.trainModel(num_objects=10, num_experiments=50, enhance_data=True, batch_size=8, show_network_summary=True, continue_from_model="idenprof_densenet-0.763500.h5") # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
88

examples/custom_model_convert_deepstack.py

-16
This file was deleted.

examples/custom_model_convert_to_tensorflow.py

-16
This file was deleted.

examples/custom_model_prediction.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
from imageai.Prediction.Custom import CustomImagePrediction
1+
from imageai.Classification.Custom import CustomImageClassification
22
import os
33

44
execution_path = os.getcwd()
55

6-
prediction = CustomImagePrediction()
7-
prediction.setModelTypeAsResNet()
8-
prediction.setModelPath(os.path.join(execution_path, "idenprof_resnet.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
6+
prediction = CustomImageClassification()
7+
prediction.setModelTypeAsResNet50()
8+
prediction.setModelPath(os.path.join(execution_path, "idenprof_resnet_ex-056_acc-0.993062.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
99
prediction.setJsonPath(os.path.join(execution_path, "idenprof.json"))
1010
prediction.loadModel(num_objects=10)
1111

12-
predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "9.jpg"), result_count=5)
12+
predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "9.jpg"), result_count=5)
1313

1414
for eachPrediction, eachProbability in zip(predictions, probabilities):
1515
print(eachPrediction , " : " , eachProbability)

examples/custom_model_training.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from imageai.Prediction.Custom import ModelTraining
1+
from imageai.Classification.Custom import ClassificationModelTrainer
22

33

4-
model_trainer = ModelTraining()
5-
model_trainer.setModelTypeAsResNet()
4+
model_trainer = ClassificationModelTrainer()
5+
model_trainer.setModelTypeAsResNet50()
66
model_trainer.setDataDirectory("idenprof")
77
model_trainer.trainModel(num_objects=10, num_experiments=200, enhance_data=True, batch_size=32, show_network_summary=True)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from imageai.Prediction.Custom import ModelTraining
1+
from imageai.Classification.Custom import ClassificationModelTrainer
22
import os
33

4-
trainer = ModelTraining()
5-
trainer.setModelTypeAsResNet()
4+
trainer = ClassificationModelTrainer()
5+
trainer.setModelTypeAsResNet50()
66
trainer.setDataDirectory("idenprof")
77
trainer.trainModel(num_objects=10, num_experiments=50, enhance_data=True, batch_size=16, show_network_summary=True,transfer_from_model="resnet50_weights_tf_dim_ordering_tf_kernels.h5", initial_num_objects=1000) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3

examples/custom_multiple_models_predict.py

-40
This file was deleted.

examples/detection_config.json

-9
This file was deleted.

examples/image_prediction.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from imageai.Prediction import ImagePrediction
1+
from imageai.Classification import ImageClassification
22
import os
33

44
execution_path = os.getcwd()
55

6-
prediction = ImagePrediction()
7-
prediction.setModelTypeAsResNet()
8-
prediction.setModelPath(os.path.join(execution_path, "resnet50_weights_tf_dim_ordering_tf_kernels.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/1.0
6+
prediction = ImageClassification()
7+
prediction.setModelTypeAsResNet50()
8+
prediction.setModelPath(os.path.join(execution_path, "resnet50_imagenet_tf.2.0.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/1.0
99
prediction.loadModel()
1010

11-
predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "1.jpg"), result_count=10)
11+
predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "1.jpg"), result_count=10)
1212
for eachPrediction, eachProbability in zip(predictions, probabilities):
1313
print(eachPrediction , " : " , eachProbability)

imageai.egg-info/PKG-INFO

-10
This file was deleted.

0 commit comments

Comments
 (0)