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.58k stars 2.19k forks source link

How to custom traning on YOLO tiny v3? #459

Open nguyenanhtuan1008 opened 4 years ago

nguyenanhtuan1008 commented 4 years ago

I follow this tutorial https://github.com/OlafenwaMoses/ImageAI/blob/master/imageai/Detection/Custom/CUSTOMDETECTIONTRAINING.md for training custom model for YOLO v3.

But How can I training my own dataset on YOLO v3 Tiny?

nekapoor commented 4 years ago

hey @nguyenanhtuan1008 you can use this blog post for a step by step guide - https://medium.com/deepquestai/train-object-detection-ai-with-6-lines-of-code-6d087063f6ff.

This blog post will have a link in it with details on how to generate your training dataset. Check that out.

Then, in the link above, you'll see code that looks like this:

from imageai.Detection.Custom import DetectionModelTrainer

trainer = DetectionModelTrainer()
trainer.setModelTypeAsYOLOv3()
trainer.setDataDirectory(data_directory="hololens")
trainer.setTrainConfig(object_names_array=["hololens"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5")
trainer.trainModel()

In the line trainer.setTrainConfig, you'll see a param called train_from_pretrained_model and it's set to pretrained-yolov3.h5.

I believe you'll just want to replace this with yolo-tiny.h5.

You can find .h5 file for yolo-tiny here - https://github.com/OlafenwaMoses/ImageAI/releases/tag/1.0/

rola93 commented 4 years ago

did @nekapoor answer worked? As far as I know, it is impossible at the moment, but maybe I'm wrong

jude90 commented 4 years ago

try reading source code of the DetectionModelTrainer at imageai/Detection/Custom/init.py . Note that its model created from func create_yolov3_model is different from the model used in CustomObjectDetection (which created from func yolo_main) . For training on tiny_yolo , you must do the same trick as func create_yolov3_model did . I want to train tiny yolo on my own too. It require a good understanding of both yolo model and keras

sinievanderben commented 2 years ago

Hi, did it work? To use a pre-trained version of TinyYOLOv3?

try reading source code of the DetectionModelTrainer at imageai/Detection/Custom/init.py . Note that its model created from func create_yolov3_model is different from the model used in CustomObjectDetection (which created from func yolo_main) . For training on tiny_yolo , you must do the same trick as func create_yolov3_model did . I want to train tiny yolo on my own too. It require a good understanding of both yolo model and keras