How to exclude COCO classes from model training process


I am trying to train an object detector using one of the existing models in Tensorflow 2’s model zoo.

I want to train the model using the dataset made available by MS COCO, converted into the tfrecord format.

This dataset contains annotations for 90 classes. I do not want to train my model on 90 classes. I am only interested in one class, the ‘person class’.

However, it is not possible to download annotations for just a single class. You must download the annotations for all classes.*

With this in mind - how can I configure my environment so that my model only trains using one of the classes in the dataset? How can i configure the training process so it ignores all the other annotations? I would like it to only try and detect the person class.

This seems like a very common use case and I’ve found numerous people asking this question while debugging but have not seen any definitive answer. It would be great to get this clear for myself and future users.

Additional info:

FiftyOne (python Coco helper API) does allow you to only download images which contain an instance of a specified class, however it will contain additional annotations.

One option could be to write code that modifies the annotation file. However, the file is vast and it risks errors. I would hope that there is a way to configure the pipeline.config or the label map so that it simply ignores annotations not relevant to training

Really been having trouble with this so any help is much appreciated. I’m also new to Tensorflow! Please let me know if you would like any additional info.

COCO is available also in TF datasets I suppose you could filter like in:

I believe I do now have it working.

The key was to just remove all the additional labels from the label.pbtxt file. Then change the number of classes in the configuration file to 1.

I had tried this before and it didn’t work. I suspect the reason was that some of my train images had pictures in it which did not contain the single class I am detecting for, and I suspect this caused it to not work as intended.

I ensured that all images had at least one instance of my class by filtering for it in fifty one.

Very surprised there was not more information on what I would expect is a very common use case. But glad it is resolved.