I have created my own dataset and when i exported my coco json file i noticed that an extra class_id is added under “categories” which seems to combine all my actual class_ids. Here is an example:
This has caused some confusion for me as well, and I don’t fully understand why they are including the super category as a class. This format works fine for RF-DETR, I assume because Roboflow made RF-DETR, but if you try to use this format for Detectron2, particularly the faster RCNN models, it creates an issue where it ignores your last class for evaluation. I assume the issue with Detectron2 has to do with the super category being recognized as a separate class. I haven’t tried any other platforms beyond that.
You can see Roboflow’s response to my similar question at…
The answer was basically “that’s the way it is”. I’ve been unable to find any documentation outside of Roboflow about a super category being included as its own class in COCO format. However, take what I have to say with a grain of salt, I am fairly new to computer vision and am by no means a professional. I’d be eager to see what the Roboflow team has to say about this.
Also, to fix the json such that it would work for Detectron2, I wrote the following to eliminate the separate super category…
import json
jsonPaths = ['/path/to/train/_annotations.coco.json','/path/to/valid/_annotations.coco.json']
for jsonPath in jsonPaths:
with open(jsonPath, 'r') as f:
data = json.load(f)
del data['categories'][0]
for i, cat in enumerate(data['categories']):
cat['id'] = i
for ann in data['annotations']:
ann['category_id'] -= 1
for ann in data['annotations']:
if ann['category_id'] > 2:
print(ann)
with open(jsonPath, "w") as f:
json.dump(data, f)
Hi @mz0g!
The class you’re referencing is the Supercategory class in COCO formatted json files that is defined when you first create your project. Unfortunately you can’t remap the super-category class, this is just part of the COCO format specification. Roboflow does not support multi-level categorization.
Even without supporting multi-level categorization, why is the super category being set as a class? This seems to be something that it unique to Roboflow’s COCO Json export. In most cases, I see the super category as a label within each of the categories. Y’all do this, but you also create an extra class for the super category.
Hi @RhysDeLoach thanks for the response! I ended up just deleting the extra combined label which seems to have worked well since none of the images actually have that label as an annotation.