How can I add one new class to MS COCO dataset and do transfer learning to achieve more classes? - tensorflow

I've annotated new image with new class according to the approach is recommended by http://www.immersivelimit.com/tutorials/create-coco-annotations-from-scratch
then I combined new class annotations with coco json annotate files and create TFrecord by running
create_coco_tf_record.py from this repository : https://github.com/tensorflow/models/tree/master/research/object_detection/dataset_tools
then I retrained faster_rcnn_resnet101 which its pretrained model is available in Tensorflow Model Zoo. I did retrain process according to this tutorial: https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10
the problem is that the loss curve didn't converge and also had oscillation!!
how can I do to get better result from retraining models?

Related

How to train custom object detection with tfrecord file

here I want to train a object detection model, so I have annotated the data using roboflow and then exported it as tfrecords and also got the (.pbtxt file) and after that I don't have any clue on how to train a can model from scratch with just 2,3 number of hidden layers. am not getting on how to use that tfrecord to fit in my model which I have created. please help me out.
tfrecord files are usually used with Tensorflow Object Detection. It's pretty old and I haven't seen it used in practice recently, but there's a Tensorflow Object Detection tutorial here that uses these tfrecord files.
If there's not a particular reason you need to use TF Object Detection I'd recommend using a newer and more well-supported model like YOLOv5 or YOLOv7.

Transfer Learning with Tensorflow's Object Detection API

I am using the Object Detection API and already have a trained model for my specific object classes.
With my task, there will be more and more object classes over time. Since retraining on the combined data sets takes very long, I am interested in a way to only train the pre-trained net on the new data.
I have found this:
Retrain Tensorflow Object detection API but since I would need to load the checkpoint on the already trained data and train it again on a combined dataset, which contains the old data, wouldn't that lead to severe over fitting on the old data?
No actually, we usually call this trick as fine-tune. The new training dataset containing both old classes and new classes enables CNN to learn a more general representation for all those classes.

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.

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?

How to Fine-tuning a Pretrained Network in Tensorflow?

Can anyone give an example of how to fine tune a pretrained imagenet network with new data and different classes similar to this:
Fine-tuning a Pretrained Network for Style Recognition
This TensorFlow tutorial describes how to retrain a image classifier for new data and new classes.