How can I use pre-trained yolov3 model and retrain train it to detect more than 80 objects - object-detection

I am using yolov3 model to detect the object. And it is able to detect 80 object.
But now I want to custom train existing model for 3 new classes and I don't want to loose pre-trained object. In other words, I want to incrementally train the model.
So, In final result I expecting that my new model will be able to detect total 83 objects.
I have followed AlexeyAB/Darknet. But at the end I am only able to detect last 3 object which i trained. And loose that 80 predefined classes.
How can I train model so it will add new classes after existing classes?

If you want to do this, you need to train your network on all the dataset used to train the 80 classes of Yolo. If you only train on your 3-classes dataset the network will "forget" the old classes it learns.
This dataset is probably COCO, you can find it online, but you should know that training a network from scratch takes lots of time.

Related

Online Learning for Yolo Network?

I want to use the Yolo Network v3 for let's say detect 5 custom object classes, for which I already have data.
So I'm going to use my train data of these classes to retrain the yolo network with pre-trained weights.
Now Imagine the case:
After some time I want to add another class to my model. Now I need to change the architecture of my model, therefore I would need to retrain my model with all 5 + 1 classes, right?
To avoid this situation I had the idea to set a maximum number of classes at the beginning, let's say 20. So I build a Yolo-architecture with 20 classes and train it with the first 5 classes for which data is available. If data of a new class is available, I will use Stochastic Gradient Descent for Online-Learning to train the model to detect the new class.
Here are my questions:
Does the model correctly learn the 5 classes at the beginning, without having data from the other 15
classes?
Is it possible by Stochastic Gradient Descent to learn new classes bit by bit?
Is there any other convenient way to handle my problem?
Thanks for any advice!

Is there a way to recognise an object in an image?

I am looking for some pre-trained deep learning model which can recognise an object in an image. Usually the images are of type used in shopping websites for products. I want to recognise what is the product in the image. I have come across some pre-trained models like VGG, Inception but they seems to be trained on some few general objects like 1000 objects. I am looking for something which is trained on more like 10000 or more.
I think the best way to do this is to build your own training set with the labels that you need to predict, then take an existing pre-trained model like VGG, remove the last fully connected layers and train the mode with your data, the process called transfer learning. Some more info here.

How to build tensorflow object detection model for custom classes and also include the 90 classess the SSD Mobilenet model contains

I am building a new tensorflow model based off of SSD V1 coco model in order to perform real time object detection in a video but i m trying to find if there is a way to build a model where I can add a new class to the existing model so that my model has all those 90 classes available in SSD MOBILENET COCO v1 model and also contains the new classes that i want to classify.
For example, I have created training data for two classes: man, woman
Now, I built a new tensorflow model that identifies a man and/or woman in a video. However, my model does not have the other 90 classes present in original SSD Mobilenet model. I am looking for a way to concatenate both models or pass more than one model to my code to detect the objects.
If you have any questions or if I am not clear, please feel free to probe me further.
The only way i find is you need to get dataset of SSD Mobilenet model on which it was trained.
Make sure all the images are present in one directory and annotations in another directory.
We should have a corresponding annotation file for each image file
ex: myimage.jpg and myimage.xml
If all the images of your customed dataset are of same formate with SSD Mobilenet model then annotate it with a tool called LabelImg.
Add that images and annotated files to respective images and annotations directory where we have already saved SSD Mobilenet.
Try regenerate new TFrecord and continue with remaining procedure on it.
You can use transfer learning with Tensorflow API.
Transfer learning allows you to load re-trained network and modify the fully connected layer by introducing your classes.
There is full description for this in the following references:
Codelab
A good explanation here
Tensorflow API here for more details
Also you can use google cloud platform for better and faster results:
I wish this helps you.
I don't think there is a way you can add your classes to the existing 90 classes without using the dataset it is previously trained with. Your only way is to use that dataset plus your own and retrain the model.

Custom Object detection using tensorflow

I have trained the object detection API using ssd_mobilenet_v1_coco_2017_11_17 model to detect a custom object. But after training, the API only detects the custom object and not the objects for which the API is already trained. ssd_mobilenet_v1_coco_2017_11_17 model detect 90 objects.
Is there any way to add more classes to an existing model so that it can detect new objects along with the one it has been trained for?
This question is already asked here and some answer could be found here.
The very last layer of the networks is softmax layer. when the network is trained, the weights of the network is optimized for the exact number of classes on the training set. So, if you need to add a new class and also the classes it was trained, the easiest way is to get the original dataset it was trained on along with your new class images. Then start the training from the pre-trained model weights. The training should converge faster as it has to do relatively little adjustments.

How to detect objects in addition to coco dataset?

I'm using tensorflow objection detection API with the coco dataset provided in the tutorial.
If I use the api to detect custom objects, how do I "add" to the list of objects being detected from the coco dataset? Is there a way to merge?
If you mean using a model which is trained on the COCO dataset to detect objects that are not in the COCO dataset, you cannot do that. I think you will need to train a model, in this case one already trained on COCO, on your new objects that you want to detect. There is a tutorial here that shows how to train a model on a custom dataset.
If you do not want to train a model you need to find one that is already trained for the objects that you want to detect.
Have I understood correctly?