From 94a2d22132c3cdafc49a4c5850a6b8a2d4ec6e61 Mon Sep 17 00:00:00 2001
From: OlafenwaMoses
Date: Tue, 5 Jan 2021 02:22:33 +0100
Subject: [PATCH] updated README for Custom Classification and Training
---
examples/custom_full_model_prediction.py | 18 -
examples/custom_model_continuos_training.py | 6 +-
examples/custom_model_convert_deepstack.py | 16 -
.../custom_model_convert_to_tensorflow.py | 16 -
examples/custom_model_prediction.py | 10 +-
examples/custom_model_training.py | 6 +-
...custom_model_transfer_learning_training.py | 6 +-
examples/custom_multiple_models_predict.py | 40 --
examples/detection_config.json | 9 -
examples/image_prediction.py | 10 +-
.../Classification/CUSTOMCLASSIFICATION.md | 142 ++----
imageai/Classification/CUSTOMTRAINING.md | 427 +-----------------
imageai/Detection/README.md | 3 +-
test/test_custom_recognition.py | 2 +-
test/test_image_recognition.py | 2 +-
test/test_model_training.py | 2 +-
16 files changed, 72 insertions(+), 643 deletions(-)
delete mode 100644 examples/custom_full_model_prediction.py
delete mode 100644 examples/custom_model_convert_deepstack.py
delete mode 100644 examples/custom_model_convert_to_tensorflow.py
delete mode 100644 examples/custom_multiple_models_predict.py
delete mode 100644 examples/detection_config.json
diff --git a/examples/custom_full_model_prediction.py b/examples/custom_full_model_prediction.py
deleted file mode 100644
index f114f18d..00000000
--- a/examples/custom_full_model_prediction.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-
-predictor = CustomImagePrediction()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_full_resnet_ex-001_acc-0.119792.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.loadFullModel(num_objects=10)
-
-
-results, probabilities = predictor.predictImage(image_input=os.path.join(execution_path, "1.jpg"), result_count=5)
-print(results)
-print(probabilities)
-
-
-
diff --git a/examples/custom_model_continuos_training.py b/examples/custom_model_continuos_training.py
index 69b7cfe8..24ccaf2a 100644
--- a/examples/custom_model_continuos_training.py
+++ b/examples/custom_model_continuos_training.py
@@ -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
diff --git a/examples/custom_model_convert_deepstack.py b/examples/custom_model_convert_deepstack.py
deleted file mode 100644
index bf515e5a..00000000
--- a/examples/custom_model_convert_deepstack.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-
-predictor = CustomImagePrediction()
-predictor.setModelTypeAsResNet()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_resnet.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.loadModel(num_objects=10)
-predictor.save_model_for_deepstack(new_model_folder= os.path.join(execution_path, "deepstack_model"), new_model_name="idenprof_resnet_deepstack.h5")
-
-
-
-
diff --git a/examples/custom_model_convert_to_tensorflow.py b/examples/custom_model_convert_to_tensorflow.py
deleted file mode 100644
index 3a2b8479..00000000
--- a/examples/custom_model_convert_to_tensorflow.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-
-predictor = CustomImagePrediction()
-predictor.setModelTypeAsResNet()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_resnet.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.loadModel(num_objects=10)
-predictor.save_model_to_tensorflow(new_model_folder= os.path.join(execution_path, "tensorflow_model"), new_model_name="idenprof_resnet_tensorflow.pb")
-
-
-
-
diff --git a/examples/custom_model_prediction.py b/examples/custom_model_prediction.py
index dbd1b138..e4b279e9 100644
--- a/examples/custom_model_prediction.py
+++ b/examples/custom_model_prediction.py
@@ -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)
\ No newline at end of file
diff --git a/examples/custom_model_training.py b/examples/custom_model_training.py
index 504beb30..f7b3c0b1 100644
--- a/examples/custom_model_training.py
+++ b/examples/custom_model_training.py
@@ -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)
diff --git a/examples/custom_model_transfer_learning_training.py b/examples/custom_model_transfer_learning_training.py
index 02cda825..deb14b57 100644
--- a/examples/custom_model_transfer_learning_training.py
+++ b/examples/custom_model_transfer_learning_training.py
@@ -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
diff --git a/examples/custom_multiple_models_predict.py b/examples/custom_multiple_models_predict.py
deleted file mode 100644
index a0f51ea0..00000000
--- a/examples/custom_multiple_models_predict.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-
-predictor = CustomImagePrediction()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_resnet.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.setModelTypeAsResNet()
-predictor.loadModel(num_objects=10)
-
-
-predictor2 = CustomImagePrediction()
-predictor2.setModelPath(model_path=os.path.join(execution_path, "idenprof_full_resnet_ex-001_acc-0.119792.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
-predictor2.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor2.loadFullModel(num_objects=10)
-
-predictor3 = CustomImagePrediction()
-predictor3.setModelPath(model_path=os.path.join(execution_path, "idenprof_inception_0.719500.h5")) # Download the model via this link https://github.com/OlafenwaMoses/ImageAI/releases/tag/models-v3
-predictor3.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor3.setModelTypeAsInceptionV3()
-predictor3.loadModel(num_objects=10)
-
-results, probabilities = predictor.predictImage(image_input=os.path.join(execution_path, "9.jpg"), result_count=5)
-print(results)
-print(probabilities)
-
-results2, probabilities2 = predictor2.predictImage(image_input=os.path.join(execution_path, "9.jpg"),
- result_count=5)
-print(results2)
-print(probabilities2)
-
-results3, probabilities3 = predictor3.predictImage(image_input=os.path.join(execution_path, "9.jpg"),
- result_count=5)
-print(results3)
-print(probabilities3)
-print("-------------------------------")
-
-
diff --git a/examples/detection_config.json b/examples/detection_config.json
deleted file mode 100644
index f3573ecf..00000000
--- a/examples/detection_config.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "labels" : [
- "hololens"
- ],
- "anchors" : [
- [160, 171, 261, 167, 301, 285],
- [78, 86, 104, 69, 138, 105],
- [37, 32, 58, 61, 62, 44]]
-}
\ No newline at end of file
diff --git a/examples/image_prediction.py b/examples/image_prediction.py
index 1d116d33..a1182570 100644
--- a/examples/image_prediction.py
+++ b/examples/image_prediction.py
@@ -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)
\ No newline at end of file
diff --git a/imageai/Classification/CUSTOMCLASSIFICATION.md b/imageai/Classification/CUSTOMCLASSIFICATION.md
index b7a88906..bffcc4ef 100644
--- a/imageai/Classification/CUSTOMCLASSIFICATION.md
+++ b/imageai/Classification/CUSTOMCLASSIFICATION.md
@@ -1,4 +1,4 @@
-# ImageAI : Custom Image Prediction
+# ImageAI : Custom Image Classification
A **DeepQuest AI** project https://deepquestai.com
---
@@ -23,8 +23,8 @@ In this example, we will be using the model trained for 20 experiments on **Iden
(You can use your own trained model and generated JSON file. This 'class' is provided mainly for the purpose to use your own custom models.)
Download the ResNet model of the model and JSON files in links below:
-- [**ResNet**](https://github.com/OlafenwaMoses/IdenProf/releases/download/v1.0/idenprof_061-0.7933.h5) _(Size = 90.4 mb)_
-- [**IdenProf model_class.json file**](https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0.1/model_class.json)
+- [**ResNet50**](https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/idenprof_resnet_ex-056_acc-0.993062.h5) _(Size = 90.4 mb)_
+- [**IdenProf model_class.json file**](https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/idenprof.json)
Great!
Once you have downloaded this model file and the JSON file, start a new python project, and then copy the model file and the JSON file to your project folder where your python files (.py files) will be.
@@ -35,18 +35,18 @@ Then write the code below into the python file:
### FirstCustomPrediction.py
```python
-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_061-0.7933.h5"))
-prediction.setJsonPath(os.path.join(execution_path, "model_class.json"))
+prediction = CustomImageClassification()
+prediction.setModelTypeAsResNet50()
+prediction.setModelPath(os.path.join(execution_path, "idenprof_resnet_ex-056_acc-0.993062.h5"))
+prediction.setJsonPath(os.path.join(execution_path, "idenprof.json"))
prediction.loadModel(num_objects=10)
-predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "4.jpg"), result_count=5)
+predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "4.jpg"), result_count=5)
for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction + " : " + eachProbability)
@@ -65,7 +65,7 @@ pilot : 2.239348366856575
The code above works as follows:
```python
-from imageai.Prediction.Custom import CustomImagePrediction
+from imageai.Classification.Custom import CustomImageClassification
import os
```
The code above imports the **ImageAI** library for custom image prediction and the python **os** class.
@@ -77,23 +77,23 @@ execution_path = os.getcwd()
The above line obtains the path to the folder that contains your python file (in this example, your FirstCustomPrediction.py).
```python
-prediction = CustomImagePrediction()
-prediction.setModelTypeAsResNet()
-prediction.setModelPath(os.path.join(execution_path, "resnet_model_ex-020_acc-0.651714.h5"))
-prediction.setJsonPath(os.path.join(execution_path, "model_class.json"))
+prediction = CustomImageClassification()
+prediction.setModelTypeAsResNet50()
+prediction.setModelPath(os.path.join(execution_path, "idenprof_resnet_ex-056_acc-0.993062.h5"))
+prediction.setJsonPath(os.path.join(execution_path, "idenprof.json"))
prediction.loadModel(num_objects=10)
```
-In the lines above, we created and instance of the `CustomImagePrediction()`
- class in the first line, then we set the model type of the prediction object to ResNet by caling the `.setModelTypeAsResNet()`
- in the second line, we set the model path of the prediction object to the path of the custom model file (`resnet_model_ex-020_acc-0.651714.h5`) we copied to the python file folder
+In the lines above, we created and instance of the `CustomImageClassification()`
+ class in the first line, then we set the model type of the prediction object to ResNet by caling the `.setModelTypeAsResNet50()`
+ in the second line, we set the model path of the prediction object to the path of the custom model file (`idenprof_resnet_ex-056_acc-0.993062.h5`) we copied to the python file folder
in the third line, we set the path to the model_class.json of the model, we load the model and parse the number of objected that can be predicted in the model.
```python
-predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "4.jpg"), result_count=5)
+predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "4.jpg"), result_count=5)
```
-In the above line, we defined 2 variables to be equal to the function called to predict an image, which is the `.predictImage()` function, into which we parsed the path to our image and also state the number of prediction results we want to have (values from 1 to 10 in this case) parsing `result_count=5`. The `.predictImage()` function will return 2 array objects with the first (**predictions**) being an array of predictions and the second (**percentage_probabilities**) being an array of the corresponding percentage probability for each prediction.
+In the above line, we defined 2 variables to be equal to the function called to predict an image, which is the `.classifyImage()` function, into which we parsed the path to our image and also state the number of prediction results we want to have (values from 1 to 10 in this case) parsing `result_count=5`. The `.classifyImage()` function will return 2 array objects with the first (**predictions**) being an array of predictions and the second (**percentage_probabilities**) being an array of the corresponding percentage probability for each prediction.
```python
for eachPrediction, eachProbability in zip(predictions, probabilities):
@@ -102,35 +102,10 @@ for eachPrediction, eachProbability in zip(predictions, probabilities):
The above line obtains each object in the **predictions** array, and also obtains the corresponding percentage probability from the **percentage_probabilities**, and finally prints the result of both to console.
-**CustomImagePrediction** class also supports the multiple predictions, input types and prediction speeds that are contained
-in the **ImagePrediction** class. Follow this [link](README.md) to see all the details.
+**CustomImageClassification** class also supports the multiple predictions, input types and prediction speeds that are contained
+in the **ImageClassification** class. Follow this [link](README.md) to see all the details.
-### Custom Model Prediction with Full Model
-
-
-**ImageAI** now allows you to perform prediction using your custom model without specifying the model type. This means you:
-1) use your custom, fully saved model that you trained with **ImageAI**
-2) use any **Keras** model that is fully saved (with weights and parameters).
-
-All you need to do is load your model using the `loadFullModel()` function instead of `loadModel()`. See the example code below for performing prediction using a fully saved model.
-
-```python
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-
-predictor = CustomImagePrediction()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_full_resnet_ex-001_acc-0.119792.h5"))
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.loadFullModel(num_objects=10)
-
-results, probabilities = predictor.predictImage(image_input=os.path.join(execution_path, "1.jpg"), result_count=5)
-print(results)
-print(probabilities)
-```
### Custom Prediction with multiple models
@@ -141,88 +116,35 @@ Now you can run multiple custom models, as many as your computer memory can acco
See the example code below for running multiple custom prediction models.
```python
-from imageai.Prediction.Custom import CustomImagePrediction
+from imageai.Classification.Custom import CustomImageClassification
import os
execution_path = os.getcwd()
-predictor = CustomImagePrediction()
+predictor = CustomImageClassification()
predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_resnet.h5"))
predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.setModelTypeAsResNet()
+predictor.setModelTypeAsResNet50()
predictor.loadModel(num_objects=10)
-predictor2 = CustomImagePrediction()
-predictor2.setModelPath(model_path=os.path.join(execution_path, "idenprof_full_resnet_ex-001_acc-0.119792.h5"))
+predictor2 = CustomImageClassification()
+predictor2.setModelPath(model_path=os.path.join(execution_path, "idenprof_inception_0.719500.h5"))
predictor2.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor2.loadFullModel(num_objects=10)
-
-predictor3 = CustomImagePrediction()
-predictor3.setModelPath(model_path=os.path.join(execution_path, "idenprof_inception_0.719500.h5"))
-predictor3.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor3.setModelTypeAsInceptionV3()
-predictor3.loadModel(num_objects=10)
+predictor2.setModelTypeAsInceptionV3()
+predictor2.loadModel(num_objects=10)
-results, probabilities = predictor.predictImage(image_input=os.path.join(execution_path, "9.jpg"), result_count=5)
+results, probabilities = predictor.classifyImage(image_input=os.path.join(execution_path, "9.jpg"), result_count=5)
print(results)
print(probabilities)
-results2, probabilities2 = predictor2.predictImage(image_input=os.path.join(execution_path, "9.jpg"),
- result_count=5)
-print(results2)
-print(probabilities2)
-results3, probabilities3 = predictor3.predictImage(image_input=os.path.join(execution_path, "9.jpg"),
+results2, probabilities2 = predictor3.classifyImage(image_input=os.path.join(execution_path, "9.jpg"),
result_count=5)
-print(results3)
-print(probabilities3)
+print(results2)
+print(probabilities2)
print("-------------------------------")
```
-### Convert custom model to Tensorflow's format
-
-
-Using the same `CustomImagePrediction` class you use for custom predictions, you can can now convert your Keras (**.h5**) models into Tensorflow's (**.pb**) model format.
-All you need to do is to call the function `save_model_to_tensorflow()` and parse in the necessary parameters as seen in the example code below.
-
-```python
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-
-predictor = CustomImagePrediction()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_full_resnet_ex-001_acc-0.119792.h5"))
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.loadFullModel(num_objects=10)
-
-results, probabilities = predictor.predictImage(image_input=os.path.join(execution_path, "1.jpg"), result_count=5)
-print(results)
-print(probabilities)
-```
-
-### Convert custom model to DeepStack's format
-
-
-With the `CustomImagePrediction` class you use for custom predictions, you can can now convert your Keras (**.h5**) models into a format deployable on [DeepStack AI Server](https://python.deepstack.cc).
-All you need to do is to call the function `save_model_for_deepstack()` and parse in the necessary parameters as seen in the example code below.
-It will generate your model and a configuration JSON file.
-
-```python
-from imageai.Prediction.Custom import CustomImagePrediction
-import os
-
-execution_path = os.getcwd()
-
-predictor = CustomImagePrediction()
-predictor.setModelTypeAsResNet()
-predictor.setModelPath(model_path=os.path.join(execution_path, "idenprof_resnet.h5"))
-predictor.setJsonPath(model_json=os.path.join(execution_path, "idenprof.json"))
-predictor.loadModel(num_objects=10)
-predictor.save_model_for_deepstack(new_model_folder= os.path.join(execution_path, "deepstack_model"), new_model_name="idenprof_resnet_deepstack.h5")
-```
-
### Documentation
We have provided full documentation for all **ImageAI** classes and functions in 3 major languages. Find links below:**
diff --git a/imageai/Classification/CUSTOMTRAINING.md b/imageai/Classification/CUSTOMTRAINING.md
index 9dd79c96..1314b0ec 100644
--- a/imageai/Classification/CUSTOMTRAINING.md
+++ b/imageai/Classification/CUSTOMTRAINING.md
@@ -4,7 +4,7 @@
**ImageAI** provides the most simple and powerful approach to training custom image prediction models
using state-of-the-art SqueezeNet, ResNet50, InceptionV3 and DenseNet
-which you can load into the `imageai.Prediction.Custom.CustomImagePrediction` class. This allows
+which you can load into the `imageai.Classification.Custom.CustomImageClassification` class. This allows
you to train your own model on any set of images that corresponds to any type of objects/persons.
The training process generates a JSON file that maps the objects types in your image dataset
and creates lots of models. You will then pick the model with the highest accuracy and perform custom
@@ -47,9 +47,9 @@ You will prepare the images as follows:
```
9. Then your training code goes as follows:
```python
- from imageai.Prediction.Custom import ModelTraining
- model_trainer = ModelTraining()
- model_trainer.setModelTypeAsResNet()
+ from imageai.Classification.Custom import ClassificationModelTrainer
+ model_trainer = ClassificationModelTrainer()
+ model_trainer.setModelTypeAsResNet50()
model_trainer.setDataDirectory("pets")
model_trainer.trainModel(num_objects=4, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)
```
@@ -58,10 +58,9 @@ You will prepare the images as follows:
Now lets take a look at how the code above works.
```python
-from imageai.Prediction.Custom import ModelTraining
-
-model_trainer = ModelTraining()
-model_trainer.setModelTypeAsResNet()
+from imageai.Classification.Custom import ClassificationModelTrainer
+model_trainer = ClassificationModelTrainer()
+model_trainer.setModelTypeAsResNet50()
model_trainer.setDataDirectory("pets")
```
@@ -86,377 +85,6 @@ images for better performance.
When you start the training, you should see something like this in the console:
```
-____________________________________________________________________________________________________
-Layer (type) Output Shape Param # Connected to
-====================================================================================================
-input_2 (InputLayer) (None, 224, 224, 3) 0
-____________________________________________________________________________________________________
-conv2d_1 (Conv2D) (None, 112, 112, 64) 9472 input_2[0][0]
-____________________________________________________________________________________________________
-batch_normalization_1 (BatchNorm (None, 112, 112, 64) 256 conv2d_1[0][0]
-____________________________________________________________________________________________________
-activation_1 (Activation) (None, 112, 112, 64) 0 batch_normalization_1[0][0]
-____________________________________________________________________________________________________
-max_pooling2d_1 (MaxPooling2D) (None, 55, 55, 64) 0 activation_1[0][0]
-____________________________________________________________________________________________________
-conv2d_3 (Conv2D) (None, 55, 55, 64) 4160 max_pooling2d_1[0][0]
-____________________________________________________________________________________________________
-batch_normalization_3 (BatchNorm (None, 55, 55, 64) 256 conv2d_3[0][0]
-____________________________________________________________________________________________________
-activation_2 (Activation) (None, 55, 55, 64) 0 batch_normalization_3[0][0]
-____________________________________________________________________________________________________
-conv2d_4 (Conv2D) (None, 55, 55, 64) 36928 activation_2[0][0]
-____________________________________________________________________________________________________
-batch_normalization_4 (BatchNorm (None, 55, 55, 64) 256 conv2d_4[0][0]
-____________________________________________________________________________________________________
-activation_3 (Activation) (None, 55, 55, 64) 0 batch_normalization_4[0][0]
-____________________________________________________________________________________________________
-conv2d_5 (Conv2D) (None, 55, 55, 256) 16640 activation_3[0][0]
-____________________________________________________________________________________________________
-conv2d_2 (Conv2D) (None, 55, 55, 256) 16640 max_pooling2d_1[0][0]
-____________________________________________________________________________________________________
-batch_normalization_5 (BatchNorm (None, 55, 55, 256) 1024 conv2d_5[0][0]
-____________________________________________________________________________________________________
-batch_normalization_2 (BatchNorm (None, 55, 55, 256) 1024 conv2d_2[0][0]
-____________________________________________________________________________________________________
-add_1 (Add) (None, 55, 55, 256) 0 batch_normalization_5[0][0]
- batch_normalization_2[0][0]
-____________________________________________________________________________________________________
-activation_4 (Activation) (None, 55, 55, 256) 0 add_1[0][0]
-____________________________________________________________________________________________________
-conv2d_6 (Conv2D) (None, 55, 55, 64) 16448 activation_4[0][0]
-____________________________________________________________________________________________________
-batch_normalization_6 (BatchNorm (None, 55, 55, 64) 256 conv2d_6[0][0]
-____________________________________________________________________________________________________
-activation_5 (Activation) (None, 55, 55, 64) 0 batch_normalization_6[0][0]
-____________________________________________________________________________________________________
-conv2d_7 (Conv2D) (None, 55, 55, 64) 36928 activation_5[0][0]
-____________________________________________________________________________________________________
-batch_normalization_7 (BatchNorm (None, 55, 55, 64) 256 conv2d_7[0][0]
-____________________________________________________________________________________________________
-activation_6 (Activation) (None, 55, 55, 64) 0 batch_normalization_7[0][0]
-____________________________________________________________________________________________________
-conv2d_8 (Conv2D) (None, 55, 55, 256) 16640 activation_6[0][0]
-____________________________________________________________________________________________________
-batch_normalization_8 (BatchNorm (None, 55, 55, 256) 1024 conv2d_8[0][0]
-____________________________________________________________________________________________________
-add_2 (Add) (None, 55, 55, 256) 0 batch_normalization_8[0][0]
- activation_4[0][0]
-____________________________________________________________________________________________________
-activation_7 (Activation) (None, 55, 55, 256) 0 add_2[0][0]
-____________________________________________________________________________________________________
-conv2d_9 (Conv2D) (None, 55, 55, 64) 16448 activation_7[0][0]
-____________________________________________________________________________________________________
-batch_normalization_9 (BatchNorm (None, 55, 55, 64) 256 conv2d_9[0][0]
-____________________________________________________________________________________________________
-activation_8 (Activation) (None, 55, 55, 64) 0 batch_normalization_9[0][0]
-____________________________________________________________________________________________________
-conv2d_10 (Conv2D) (None, 55, 55, 64) 36928 activation_8[0][0]
-____________________________________________________________________________________________________
-batch_normalization_10 (BatchNor (None, 55, 55, 64) 256 conv2d_10[0][0]
-____________________________________________________________________________________________________
-activation_9 (Activation) (None, 55, 55, 64) 0 batch_normalization_10[0][0]
-____________________________________________________________________________________________________
-conv2d_11 (Conv2D) (None, 55, 55, 256) 16640 activation_9[0][0]
-____________________________________________________________________________________________________
-batch_normalization_11 (BatchNor (None, 55, 55, 256) 1024 conv2d_11[0][0]
-____________________________________________________________________________________________________
-add_3 (Add) (None, 55, 55, 256) 0 batch_normalization_11[0][0]
- activation_7[0][0]
-____________________________________________________________________________________________________
-activation_10 (Activation) (None, 55, 55, 256) 0 add_3[0][0]
-____________________________________________________________________________________________________
-conv2d_13 (Conv2D) (None, 28, 28, 128) 32896 activation_10[0][0]
-____________________________________________________________________________________________________
-batch_normalization_13 (BatchNor (None, 28, 28, 128) 512 conv2d_13[0][0]
-____________________________________________________________________________________________________
-activation_11 (Activation) (None, 28, 28, 128) 0 batch_normalization_13[0][0]
-____________________________________________________________________________________________________
-conv2d_14 (Conv2D) (None, 28, 28, 128) 147584 activation_11[0][0]
-____________________________________________________________________________________________________
-batch_normalization_14 (BatchNor (None, 28, 28, 128) 512 conv2d_14[0][0]
-____________________________________________________________________________________________________
-activation_12 (Activation) (None, 28, 28, 128) 0 batch_normalization_14[0][0]
-____________________________________________________________________________________________________
-conv2d_15 (Conv2D) (None, 28, 28, 512) 66048 activation_12[0][0]
-____________________________________________________________________________________________________
-conv2d_12 (Conv2D) (None, 28, 28, 512) 131584 activation_10[0][0]
-____________________________________________________________________________________________________
-batch_normalization_15 (BatchNor (None, 28, 28, 512) 2048 conv2d_15[0][0]
-____________________________________________________________________________________________________
-batch_normalization_12 (BatchNor (None, 28, 28, 512) 2048 conv2d_12[0][0]
-____________________________________________________________________________________________________
-add_4 (Add) (None, 28, 28, 512) 0 batch_normalization_15[0][0]
- batch_normalization_12[0][0]
-____________________________________________________________________________________________________
-activation_13 (Activation) (None, 28, 28, 512) 0 add_4[0][0]
-____________________________________________________________________________________________________
-conv2d_16 (Conv2D) (None, 28, 28, 128) 65664 activation_13[0][0]
-____________________________________________________________________________________________________
-batch_normalization_16 (BatchNor (None, 28, 28, 128) 512 conv2d_16[0][0]
-____________________________________________________________________________________________________
-activation_14 (Activation) (None, 28, 28, 128) 0 batch_normalization_16[0][0]
-____________________________________________________________________________________________________
-conv2d_17 (Conv2D) (None, 28, 28, 128) 147584 activation_14[0][0]
-____________________________________________________________________________________________________
-batch_normalization_17 (BatchNor (None, 28, 28, 128) 512 conv2d_17[0][0]
-____________________________________________________________________________________________________
-activation_15 (Activation) (None, 28, 28, 128) 0 batch_normalization_17[0][0]
-____________________________________________________________________________________________________
-conv2d_18 (Conv2D) (None, 28, 28, 512) 66048 activation_15[0][0]
-____________________________________________________________________________________________________
-batch_normalization_18 (BatchNor (None, 28, 28, 512) 2048 conv2d_18[0][0]
-____________________________________________________________________________________________________
-add_5 (Add) (None, 28, 28, 512) 0 batch_normalization_18[0][0]
- activation_13[0][0]
-____________________________________________________________________________________________________
-activation_16 (Activation) (None, 28, 28, 512) 0 add_5[0][0]
-____________________________________________________________________________________________________
-conv2d_19 (Conv2D) (None, 28, 28, 128) 65664 activation_16[0][0]
-____________________________________________________________________________________________________
-batch_normalization_19 (BatchNor (None, 28, 28, 128) 512 conv2d_19[0][0]
-____________________________________________________________________________________________________
-activation_17 (Activation) (None, 28, 28, 128) 0 batch_normalization_19[0][0]
-____________________________________________________________________________________________________
-conv2d_20 (Conv2D) (None, 28, 28, 128) 147584 activation_17[0][0]
-____________________________________________________________________________________________________
-batch_normalization_20 (BatchNor (None, 28, 28, 128) 512 conv2d_20[0][0]
-____________________________________________________________________________________________________
-activation_18 (Activation) (None, 28, 28, 128) 0 batch_normalization_20[0][0]
-____________________________________________________________________________________________________
-conv2d_21 (Conv2D) (None, 28, 28, 512) 66048 activation_18[0][0]
-____________________________________________________________________________________________________
-batch_normalization_21 (BatchNor (None, 28, 28, 512) 2048 conv2d_21[0][0]
-____________________________________________________________________________________________________
-add_6 (Add) (None, 28, 28, 512) 0 batch_normalization_21[0][0]
- activation_16[0][0]
-____________________________________________________________________________________________________
-activation_19 (Activation) (None, 28, 28, 512) 0 add_6[0][0]
-____________________________________________________________________________________________________
-conv2d_22 (Conv2D) (None, 28, 28, 128) 65664 activation_19[0][0]
-____________________________________________________________________________________________________
-batch_normalization_22 (BatchNor (None, 28, 28, 128) 512 conv2d_22[0][0]
-____________________________________________________________________________________________________
-activation_20 (Activation) (None, 28, 28, 128) 0 batch_normalization_22[0][0]
-____________________________________________________________________________________________________
-conv2d_23 (Conv2D) (None, 28, 28, 128) 147584 activation_20[0][0]
-____________________________________________________________________________________________________
-batch_normalization_23 (BatchNor (None, 28, 28, 128) 512 conv2d_23[0][0]
-____________________________________________________________________________________________________
-activation_21 (Activation) (None, 28, 28, 128) 0 batch_normalization_23[0][0]
-____________________________________________________________________________________________________
-conv2d_24 (Conv2D) (None, 28, 28, 512) 66048 activation_21[0][0]
-____________________________________________________________________________________________________
-batch_normalization_24 (BatchNor (None, 28, 28, 512) 2048 conv2d_24[0][0]
-____________________________________________________________________________________________________
-add_7 (Add) (None, 28, 28, 512) 0 batch_normalization_24[0][0]
- activation_19[0][0]
-____________________________________________________________________________________________________
-activation_22 (Activation) (None, 28, 28, 512) 0 add_7[0][0]
-____________________________________________________________________________________________________
-conv2d_26 (Conv2D) (None, 14, 14, 256) 131328 activation_22[0][0]
-____________________________________________________________________________________________________
-batch_normalization_26 (BatchNor (None, 14, 14, 256) 1024 conv2d_26[0][0]
-____________________________________________________________________________________________________
-activation_23 (Activation) (None, 14, 14, 256) 0 batch_normalization_26[0][0]
-____________________________________________________________________________________________________
-conv2d_27 (Conv2D) (None, 14, 14, 256) 590080 activation_23[0][0]
-____________________________________________________________________________________________________
-batch_normalization_27 (BatchNor (None, 14, 14, 256) 1024 conv2d_27[0][0]
-____________________________________________________________________________________________________
-activation_24 (Activation) (None, 14, 14, 256) 0 batch_normalization_27[0][0]
-____________________________________________________________________________________________________
-conv2d_28 (Conv2D) (None, 14, 14, 1024) 263168 activation_24[0][0]
-____________________________________________________________________________________________________
-conv2d_25 (Conv2D) (None, 14, 14, 1024) 525312 activation_22[0][0]
-____________________________________________________________________________________________________
-batch_normalization_28 (BatchNor (None, 14, 14, 1024) 4096 conv2d_28[0][0]
-____________________________________________________________________________________________________
-batch_normalization_25 (BatchNor (None, 14, 14, 1024) 4096 conv2d_25[0][0]
-____________________________________________________________________________________________________
-add_8 (Add) (None, 14, 14, 1024) 0 batch_normalization_28[0][0]
- batch_normalization_25[0][0]
-____________________________________________________________________________________________________
-activation_25 (Activation) (None, 14, 14, 1024) 0 add_8[0][0]
-____________________________________________________________________________________________________
-conv2d_29 (Conv2D) (None, 14, 14, 256) 262400 activation_25[0][0]
-____________________________________________________________________________________________________
-batch_normalization_29 (BatchNor (None, 14, 14, 256) 1024 conv2d_29[0][0]
-____________________________________________________________________________________________________
-activation_26 (Activation) (None, 14, 14, 256) 0 batch_normalization_29[0][0]
-____________________________________________________________________________________________________
-conv2d_30 (Conv2D) (None, 14, 14, 256) 590080 activation_26[0][0]
-____________________________________________________________________________________________________
-batch_normalization_30 (BatchNor (None, 14, 14, 256) 1024 conv2d_30[0][0]
-____________________________________________________________________________________________________
-activation_27 (Activation) (None, 14, 14, 256) 0 batch_normalization_30[0][0]
-____________________________________________________________________________________________________
-conv2d_31 (Conv2D) (None, 14, 14, 1024) 263168 activation_27[0][0]
-____________________________________________________________________________________________________
-batch_normalization_31 (BatchNor (None, 14, 14, 1024) 4096 conv2d_31[0][0]
-____________________________________________________________________________________________________
-add_9 (Add) (None, 14, 14, 1024) 0 batch_normalization_31[0][0]
- activation_25[0][0]
-____________________________________________________________________________________________________
-activation_28 (Activation) (None, 14, 14, 1024) 0 add_9[0][0]
-____________________________________________________________________________________________________
-conv2d_32 (Conv2D) (None, 14, 14, 256) 262400 activation_28[0][0]
-____________________________________________________________________________________________________
-batch_normalization_32 (BatchNor (None, 14, 14, 256) 1024 conv2d_32[0][0]
-____________________________________________________________________________________________________
-activation_29 (Activation) (None, 14, 14, 256) 0 batch_normalization_32[0][0]
-____________________________________________________________________________________________________
-conv2d_33 (Conv2D) (None, 14, 14, 256) 590080 activation_29[0][0]
-____________________________________________________________________________________________________
-batch_normalization_33 (BatchNor (None, 14, 14, 256) 1024 conv2d_33[0][0]
-____________________________________________________________________________________________________
-activation_30 (Activation) (None, 14, 14, 256) 0 batch_normalization_33[0][0]
-____________________________________________________________________________________________________
-conv2d_34 (Conv2D) (None, 14, 14, 1024) 263168 activation_30[0][0]
-____________________________________________________________________________________________________
-batch_normalization_34 (BatchNor (None, 14, 14, 1024) 4096 conv2d_34[0][0]
-____________________________________________________________________________________________________
-add_10 (Add) (None, 14, 14, 1024) 0 batch_normalization_34[0][0]
- activation_28[0][0]
-____________________________________________________________________________________________________
-activation_31 (Activation) (None, 14, 14, 1024) 0 add_10[0][0]
-____________________________________________________________________________________________________
-conv2d_35 (Conv2D) (None, 14, 14, 256) 262400 activation_31[0][0]
-____________________________________________________________________________________________________
-batch_normalization_35 (BatchNor (None, 14, 14, 256) 1024 conv2d_35[0][0]
-____________________________________________________________________________________________________
-activation_32 (Activation) (None, 14, 14, 256) 0 batch_normalization_35[0][0]
-____________________________________________________________________________________________________
-conv2d_36 (Conv2D) (None, 14, 14, 256) 590080 activation_32[0][0]
-____________________________________________________________________________________________________
-batch_normalization_36 (BatchNor (None, 14, 14, 256) 1024 conv2d_36[0][0]
-____________________________________________________________________________________________________
-activation_33 (Activation) (None, 14, 14, 256) 0 batch_normalization_36[0][0]
-____________________________________________________________________________________________________
-conv2d_37 (Conv2D) (None, 14, 14, 1024) 263168 activation_33[0][0]
-____________________________________________________________________________________________________
-batch_normalization_37 (BatchNor (None, 14, 14, 1024) 4096 conv2d_37[0][0]
-____________________________________________________________________________________________________
-add_11 (Add) (None, 14, 14, 1024) 0 batch_normalization_37[0][0]
- activation_31[0][0]
-____________________________________________________________________________________________________
-activation_34 (Activation) (None, 14, 14, 1024) 0 add_11[0][0]
-____________________________________________________________________________________________________
-conv2d_38 (Conv2D) (None, 14, 14, 256) 262400 activation_34[0][0]
-____________________________________________________________________________________________________
-batch_normalization_38 (BatchNor (None, 14, 14, 256) 1024 conv2d_38[0][0]
-____________________________________________________________________________________________________
-activation_35 (Activation) (None, 14, 14, 256) 0 batch_normalization_38[0][0]
-____________________________________________________________________________________________________
-conv2d_39 (Conv2D) (None, 14, 14, 256) 590080 activation_35[0][0]
-____________________________________________________________________________________________________
-batch_normalization_39 (BatchNor (None, 14, 14, 256) 1024 conv2d_39[0][0]
-____________________________________________________________________________________________________
-activation_36 (Activation) (None, 14, 14, 256) 0 batch_normalization_39[0][0]
-____________________________________________________________________________________________________
-conv2d_40 (Conv2D) (None, 14, 14, 1024) 263168 activation_36[0][0]
-____________________________________________________________________________________________________
-batch_normalization_40 (BatchNor (None, 14, 14, 1024) 4096 conv2d_40[0][0]
-____________________________________________________________________________________________________
-add_12 (Add) (None, 14, 14, 1024) 0 batch_normalization_40[0][0]
- activation_34[0][0]
-____________________________________________________________________________________________________
-activation_37 (Activation) (None, 14, 14, 1024) 0 add_12[0][0]
-____________________________________________________________________________________________________
-conv2d_41 (Conv2D) (None, 14, 14, 256) 262400 activation_37[0][0]
-____________________________________________________________________________________________________
-batch_normalization_41 (BatchNor (None, 14, 14, 256) 1024 conv2d_41[0][0]
-____________________________________________________________________________________________________
-activation_38 (Activation) (None, 14, 14, 256) 0 batch_normalization_41[0][0]
-____________________________________________________________________________________________________
-conv2d_42 (Conv2D) (None, 14, 14, 256) 590080 activation_38[0][0]
-____________________________________________________________________________________________________
-batch_normalization_42 (BatchNor (None, 14, 14, 256) 1024 conv2d_42[0][0]
-____________________________________________________________________________________________________
-activation_39 (Activation) (None, 14, 14, 256) 0 batch_normalization_42[0][0]
-____________________________________________________________________________________________________
-conv2d_43 (Conv2D) (None, 14, 14, 1024) 263168 activation_39[0][0]
-____________________________________________________________________________________________________
-batch_normalization_43 (BatchNor (None, 14, 14, 1024) 4096 conv2d_43[0][0]
-____________________________________________________________________________________________________
-add_13 (Add) (None, 14, 14, 1024) 0 batch_normalization_43[0][0]
- activation_37[0][0]
-____________________________________________________________________________________________________
-activation_40 (Activation) (None, 14, 14, 1024) 0 add_13[0][0]
-____________________________________________________________________________________________________
-conv2d_45 (Conv2D) (None, 7, 7, 512) 524800 activation_40[0][0]
-____________________________________________________________________________________________________
-batch_normalization_45 (BatchNor (None, 7, 7, 512) 2048 conv2d_45[0][0]
-____________________________________________________________________________________________________
-activation_41 (Activation) (None, 7, 7, 512) 0 batch_normalization_45[0][0]
-____________________________________________________________________________________________________
-conv2d_46 (Conv2D) (None, 7, 7, 512) 2359808 activation_41[0][0]
-____________________________________________________________________________________________________
-batch_normalization_46 (BatchNor (None, 7, 7, 512) 2048 conv2d_46[0][0]
-____________________________________________________________________________________________________
-activation_42 (Activation) (None, 7, 7, 512) 0 batch_normalization_46[0][0]
-____________________________________________________________________________________________________
-conv2d_47 (Conv2D) (None, 7, 7, 2048) 1050624 activation_42[0][0]
-____________________________________________________________________________________________________
-conv2d_44 (Conv2D) (None, 7, 7, 2048) 2099200 activation_40[0][0]
-____________________________________________________________________________________________________
-batch_normalization_47 (BatchNor (None, 7, 7, 2048) 8192 conv2d_47[0][0]
-____________________________________________________________________________________________________
-batch_normalization_44 (BatchNor (None, 7, 7, 2048) 8192 conv2d_44[0][0]
-____________________________________________________________________________________________________
-add_14 (Add) (None, 7, 7, 2048) 0 batch_normalization_47[0][0]
- batch_normalization_44[0][0]
-____________________________________________________________________________________________________
-activation_43 (Activation) (None, 7, 7, 2048) 0 add_14[0][0]
-____________________________________________________________________________________________________
-conv2d_48 (Conv2D) (None, 7, 7, 512) 1049088 activation_43[0][0]
-____________________________________________________________________________________________________
-batch_normalization_48 (BatchNor (None, 7, 7, 512) 2048 conv2d_48[0][0]
-____________________________________________________________________________________________________
-activation_44 (Activation) (None, 7, 7, 512) 0 batch_normalization_48[0][0]
-____________________________________________________________________________________________________
-conv2d_49 (Conv2D) (None, 7, 7, 512) 2359808 activation_44[0][0]
-____________________________________________________________________________________________________
-batch_normalization_49 (BatchNor (None, 7, 7, 512) 2048 conv2d_49[0][0]
-____________________________________________________________________________________________________
-activation_45 (Activation) (None, 7, 7, 512) 0 batch_normalization_49[0][0]
-____________________________________________________________________________________________________
-conv2d_50 (Conv2D) (None, 7, 7, 2048) 1050624 activation_45[0][0]
-____________________________________________________________________________________________________
-batch_normalization_50 (BatchNor (None, 7, 7, 2048) 8192 conv2d_50[0][0]
-____________________________________________________________________________________________________
-add_15 (Add) (None, 7, 7, 2048) 0 batch_normalization_50[0][0]
- activation_43[0][0]
-____________________________________________________________________________________________________
-activation_46 (Activation) (None, 7, 7, 2048) 0 add_15[0][0]
-____________________________________________________________________________________________________
-conv2d_51 (Conv2D) (None, 7, 7, 512) 1049088 activation_46[0][0]
-____________________________________________________________________________________________________
-batch_normalization_51 (BatchNor (None, 7, 7, 512) 2048 conv2d_51[0][0]
-____________________________________________________________________________________________________
-activation_47 (Activation) (None, 7, 7, 512) 0 batch_normalization_51[0][0]
-____________________________________________________________________________________________________
-conv2d_52 (Conv2D) (None, 7, 7, 512) 2359808 activation_47[0][0]
-____________________________________________________________________________________________________
-batch_normalization_52 (BatchNor (None, 7, 7, 512) 2048 conv2d_52[0][0]
-____________________________________________________________________________________________________
-activation_48 (Activation) (None, 7, 7, 512) 0 batch_normalization_52[0][0]
-____________________________________________________________________________________________________
-conv2d_53 (Conv2D) (None, 7, 7, 2048) 1050624 activation_48[0][0]
-____________________________________________________________________________________________________
-batch_normalization_53 (BatchNor (None, 7, 7, 2048) 8192 conv2d_53[0][0]
-____________________________________________________________________________________________________
-add_16 (Add) (None, 7, 7, 2048) 0 batch_normalization_53[0][0]
- activation_46[0][0]
-____________________________________________________________________________________________________
-activation_49 (Activation) (None, 7, 7, 2048) 0 add_16[0][0]
-____________________________________________________________________________________________________
-global_avg_pooling (GlobalAverag (None, 2048) 0 activation_49[0][0]
-____________________________________________________________________________________________________
-dense_1 (Dense) (None, 10) 20490 global_avg_pooling[0][0]
-____________________________________________________________________________________________________
-activation_50 (Activation) (None, 10) 0 dense_1[0][0]
-====================================================================================================
Total params: 23,608,202
Trainable params: 23,555,082
Non-trainable params: 53,120
@@ -507,22 +135,6 @@ Let us explain the details shown above:
Once you are done training your custom model, you can use the "CustomImagePrediction" class to perform image prediction with your model. Simply follow the link below.
[imageai/Classification/CUSTOMCLASSIFICATION.md](https://github.com/OlafenwaMoses/ImageAI/blob/master/imageai/Classification/CUSTOMCLASSIFICATION.md)
-### Saving Full Custom Model
-
-
-**ImageAI** now allows you to your custom model in full during training, which ensures you can perform custom prediction without necessarily specifying the network type.
-All you need to do is set the paramater `save_full_model` to `True` in your `trainModel()` function.
-See an example code below.
-
-```python
-from imageai.Prediction.Custom import ModelTraining
-import os
-
-trainer = ModelTraining()
-trainer.setModelTypeAsDenseNet()
-trainer.setDataDirectory("idenprof")
-trainer.trainModel(num_objects=10, num_experiments=50, enhance_data=True, batch_size=16, show_network_summary=True, save_full_model=True)
-```
### Training on the IdenProf data
@@ -537,7 +149,7 @@ import requests
import shutil
from zipfile import ZipFile
import os
-from imageai.Prediction.Custom import ModelTraining
+from imageai.Classification.Custom import ClassificationModelTrainer
execution_path = os.getcwd()
@@ -591,8 +203,8 @@ if(len(os.listdir(DATASET_TEST_DIR)) < 10):
extract.close()
-model_trainer = ModelTraining()
-model_trainer.setModelTypeAsResNet()
+model_trainer = ClassificationModelTrainer()
+model_trainer.setModelTypeAsResNet50()
model_trainer.setDataDirectory(DATASET_DIR)
model_trainer.trainModel(num_objects=10, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)
```
@@ -607,11 +219,11 @@ All you need to do is specify the `continue_from_model` parameter to the path of
See an example code below.
```python
-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")
```
@@ -625,20 +237,15 @@ To ensure they can still train very accurate custom models using few number of i
All you need to do is specify the `transfer_from_model` parameter to the path of the pre-trained model, `initial_num_objects` parameter which corresponds to the number of objects in the previous dataset the pre-trained model was trained on, all in your `trainModel()` function. See an example code below, showing how to perform transfer learning from a ResNet50 model trained on the ImageNet dataset.
```python
-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=32, show_network_summary=True,transfer_from_model="resnet50_weights_tf_dim_ordering_tf_kernels.h5", initial_num_objects=1000)
+trainer.trainModel(num_objects=10, num_experiments=50, enhance_data=True, batch_size=32, show_network_summary=True,transfer_from_model="resnet50_imagenet_tf.2.0.h5", initial_num_objects=1000)
```
-### Submitting Custom Model
-
-We are providing an opportunity for anyone that uses to train a model to submit the model and its JSON mapping file
- and have it listed in this repository. Reach to the details below should intend to share your trained model in this repository.
-
### Contact Developer
- **Moses Olafenwa**
diff --git a/imageai/Detection/README.md b/imageai/Detection/README.md
index 1798082a..44cd80ea 100644
--- a/imageai/Detection/README.md
+++ b/imageai/Detection/README.md
@@ -14,10 +14,9 @@ A **DeepQuest AI** project [https://deepquestai.com](https://deepquestai.com)
ImageAI provides very convenient and powerful methods to perform object detection on images and extract each object from the image. The object detection class supports RetinaNet, YOLOv3 and TinyYOLOv3. To start performing object detection, you must download the RetinaNet, YOLOv3 or TinyYOLOv3 object detection model via the links below:
-* **[RetinaNet](https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5)** _(Size = 145 mb, high performance and accuracy, with longer detection time)_
+* **[RetinaNet](https://github.com/OlafenwaMoses/ImageAI/releases/download/essentials-v5/resnet50_coco_best_v2.1.0.h5)** _(Size = 145 mb, high performance and accuracy, with longer detection time)_
* **[YOLOv3](https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo.h5)** _(Size = 237 mb, moderate performance and accuracy, with a moderate detection time)_
* **[TinyYOLOv3](https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo-tiny.h5)** _(Size = 34 mb, optimized for speed and moderate performance, with fast detection time)_
-* **[RetinaNet](https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5)** _(Size = 145 mb, high performance and accuracy, with longer detection time)_
Once you download the object detection model file, you should copy the model file to the your project folder where your .py files will be.
diff --git a/test/test_custom_recognition.py b/test/test_custom_recognition.py
index 8b61a269..a93f572b 100644
--- a/test/test_custom_recognition.py
+++ b/test/test_custom_recognition.py
@@ -1,4 +1,4 @@
-from imageai.Prediction.Custom import CustomImageClassification
+from imageai.Classification.Custom import CustomImageClassification
import pytest
from os.path import dirname
import os
diff --git a/test/test_image_recognition.py b/test/test_image_recognition.py
index 4a79a289..547764cc 100644
--- a/test/test_image_recognition.py
+++ b/test/test_image_recognition.py
@@ -1,4 +1,4 @@
-from imageai.Prediction import ImageClassification
+from imageai.Classification import ImageClassification
import os
import cv2
import pytest
diff --git a/test/test_model_training.py b/test/test_model_training.py
index 8341c0eb..d9d4d00b 100644
--- a/test/test_model_training.py
+++ b/test/test_model_training.py
@@ -1,4 +1,4 @@
-from imageai.Prediction.Custom import ClassificationModelTrainer
+from imageai.Classification.Custom import ClassificationModelTrainer
import os
import pytest
import shutil