Skip to content

Commit

Permalink
Merge pull request #618 from OlafenwaMoses/tensorflow2.0-port
Browse files Browse the repository at this point in the history
Updated for Tensorflow 2.4.0
  • Loading branch information
OlafenwaMoses authored Jan 5, 2021
2 parents 1262edc + 94a2d22 commit c4baba9
Show file tree
Hide file tree
Showing 163 changed files with 6,427 additions and 9,015 deletions.
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ nosetests.xml
coverage.xml
*.cover
.hypothesis/
*.egg-info
*.egg-info

# VSCode files
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: xenial
sudo: required
language: python
python:
- '3.5'
- '3.7.6'
install:
- pip install -r requirements.txt
- pip install pytest
Expand All @@ -14,12 +14,12 @@ script:
- mkdir data-temp
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/DenseNet-BC-121-32.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/inception_v3_weights_tf_dim_ordering_tf_kernels.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_weights_tf_dim_ordering_tf_kernels.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/squeezenet_weights_tf_dim_ordering_tf_kernels.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/resnet50_imagenet_tf.2.0.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/mobilenet_v2.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_densenet-0.763500.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_full_resnet_ex-001_acc-0.119792.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_resnet.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/idenprof_resnet_ex-056_acc-0.993062.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/resnet50_coco_best_v2.1.0.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo-tiny.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/essential-v4/pretrained-yolov3.h5
Expand Down
69 changes: 42 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ImageAI (v2.1.5)
# ImageAI (v2.1.6)

![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)


[![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)

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
and few lines of code.
Expand All @@ -9,7 +11,9 @@ An open-source python library built to empower developers to build applications

<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>

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

![](logo1.png)

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


**New Release : ImageAI 2.1.5**
**New Release : ImageAI 2.1.6**

What's new:

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


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

- Python 3.5.1 (and later versions)
- Tensorflow 1.4.0 (and later versions) **(Tensorflow 2.0 coming soon)**
- Python 3.7.6
- Tensorflow 2.4.0
- OpenCV
- Keras 2.x

```bash
pip install -U tensorflow keras opencv-python
- Keras 2.4.3

You can install all the dependencies by running the commands below

**Tensorflow**
```bash
pip install tensorflow==2.4.0
```

or **Tensorflow GPU** if you have NVIDIA GPU with CUDA and cuDNN installed.
```bash
pip install tensorflow-gpu==2.4.0
```

**Other Dependencies**
```bash
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
```

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

```bash
pip3 install imageai --upgrade
pip install imageai --upgrade
```

### Image Prediction
Expand All @@ -102,11 +121,11 @@ minivan : 1.7487050965428352
```

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

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

[>>> Tutorial & Guide](imageai/Prediction/README.md)
[>>> Tutorial & Guide](imageai/Classification/README.md)


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

[>>> Tutorials & Documentation](imageai/Prediction/CUSTOMTRAINING.md)
[>>> Tutorials & Documentation](imageai/Classification/CUSTOMTRAINING.md)


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


[>>> Tutorials & Documentation](imageai/Prediction/CUSTOMPREDICTION.md)
[>>> Tutorials & Documentation](imageai/Classification/CUSTOMCLASSIFICATION.md)



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


<div id="sponsors"></div>

### >>> Basic Sponsors

[<img src="https://avatars1.githubusercontent.com/u/46119184?s=460&v=" alt="David Lopez" style="width:50px;"/>](https://github.com/daviddbarrero)


### References
<div id="ref"></div>
Expand Down Expand Up @@ -398,3 +411,5 @@ You can cite **ImageAI** in your projects and research papers via the **BibTeX**
[https://arxiv.org/abs/1804.02767](https://arxiv.org/abs/1804.02767)
14. Experiencor, Training and Detecting Objects with YOLO3
[https://github.com/experiencor/keras-yolo3](https://github.com/experiencor/keras-yolo3)
15. MobileNetV2: Inverted Residuals and Linear Bottlenecks
[https://arxiv.org/abs/1801.04381](https://arxiv.org/abs/1801.04381)
18 changes: 0 additions & 18 deletions examples/custom_full_model_prediction.py

This file was deleted.

6 changes: 3 additions & 3 deletions examples/custom_model_continuos_training.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from imageai.Prediction.Custom import ModelTraining
from imageai.Classification.Custom import ClassificationModelTrainer
import os

trainer = ModelTraining()
trainer.setModelTypeAsDenseNet()
trainer = ClassificationModelTrainer()
trainer.setModelTypeAsDenseNet121()
trainer.setDataDirectory("idenprof")
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

16 changes: 0 additions & 16 deletions examples/custom_model_convert_deepstack.py

This file was deleted.

16 changes: 0 additions & 16 deletions examples/custom_model_convert_to_tensorflow.py

This file was deleted.

10 changes: 5 additions & 5 deletions examples/custom_model_prediction.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from imageai.Prediction.Custom import CustomImagePrediction
from imageai.Classification.Custom import CustomImageClassification
import os

execution_path = os.getcwd()

prediction = CustomImagePrediction()
prediction.setModelTypeAsResNet()
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
prediction = CustomImageClassification()
prediction.setModelTypeAsResNet50()
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
prediction.setJsonPath(os.path.join(execution_path, "idenprof.json"))
prediction.loadModel(num_objects=10)

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

for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction , " : " , eachProbability)
6 changes: 3 additions & 3 deletions examples/custom_model_training.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from imageai.Prediction.Custom import ModelTraining
from imageai.Classification.Custom import ClassificationModelTrainer


model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer = ClassificationModelTrainer()
model_trainer.setModelTypeAsResNet50()
model_trainer.setDataDirectory("idenprof")
model_trainer.trainModel(num_objects=10, num_experiments=200, enhance_data=True, batch_size=32, show_network_summary=True)
6 changes: 3 additions & 3 deletions examples/custom_model_transfer_learning_training.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from imageai.Prediction.Custom import ModelTraining
from imageai.Classification.Custom import ClassificationModelTrainer
import os

trainer = ModelTraining()
trainer.setModelTypeAsResNet()
trainer = ClassificationModelTrainer()
trainer.setModelTypeAsResNet50()
trainer.setDataDirectory("idenprof")
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
40 changes: 0 additions & 40 deletions examples/custom_multiple_models_predict.py

This file was deleted.

9 changes: 0 additions & 9 deletions examples/detection_config.json

This file was deleted.

10 changes: 5 additions & 5 deletions examples/image_prediction.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from imageai.Prediction import ImagePrediction
from imageai.Classification import ImageClassification
import os

execution_path = os.getcwd()

prediction = ImagePrediction()
prediction.setModelTypeAsResNet()
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
prediction = ImageClassification()
prediction.setModelTypeAsResNet50()
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
prediction.loadModel()

predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "1.jpg"), result_count=10)
predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "1.jpg"), result_count=10)
for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction , " : " , eachProbability)
10 changes: 0 additions & 10 deletions imageai.egg-info/PKG-INFO

This file was deleted.

Loading

0 comments on commit c4baba9

Please sign in to comment.