OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.55k stars 2.19k forks source link

How to do transfer_from_model from yolo or retinanet models? #227

Closed nguyenlequocdat04 closed 5 years ago

nguyenlequocdat04 commented 5 years ago
from imageai.Prediction.Custom import ModelTraining
import os
trainer = ModelTraining()
trainer.setModelTypeAsResNet()
trainer.setDataDirectory("dataset")
trainer.trainModel(num_objects=1, num_experiments=50, enhance_data=True, 
                   batch_size=32, show_network_summary=True,
                   transfer_from_model="model/resnet50_coco_best_v2.0.1.h5", 
                   initial_num_objects=1000)

I try to make a model can detect 80 objects in "resnet50_coco_best_v2.0.1" but have some additions. But i got error: ValueError: You are trying to load a weight file containing 116 layers into a model with 107 layers. Am i doing it right? If not, can you suggest any solution. Thanks so much!

OlafenwaMoses commented 5 years ago

The resnet50_coco_best_v2.0.1.h5 model is for object detection. However, the ModelTraining() class is for training prediction models and not for detection models. That is why it thrown an error when you attempted to transfer from the detection model.

We are working on providing support for training custom object detection models and it will be released soon. Follow this thread for more on this. #8