How to merge classes post-training in TensorFlow Object Detection API

Viewed 319

TF OD API has a label map in which you tell the model what are your classes, give them ID's and names. Let's say I have a trained model on a given dataset, say MS COCO, and I want to merge/unify some of the classes post-training (i.e. without any fine-tuning). For example, I want to merge bicycle and motorcycle to the class "two wheeler", merge the entire food super-category to the single class "food", and merge the entire animals super-category to the single class "animal". Can I do it using the current API by modifying the label map, the label map util, or any other option?

One can do it in a "sophisticated way" by adding the confidences of the relevant classes into a single confidence (assuming the confidences sum up to 1), but I'm okay with just applying "any" to the class with the highest confidence, i.e. if the class with the highest confidence is any of the classes in the merged set, then assign it with the merged set class.

I have tried modifying the label map by changing the names of the classes I want to merge to the merged set class (e.g. naming "bird", "cat", "dog", etc. simply as "animal"), but when evaluating the model it still treats to the classes in the set differently, by their ID. On the other hand, I can't omit IDs I want to merge, since I still want the to detect them all, only treat them as the same.

Thanks in advance.

0 Answers
Related