voxel51 / fiftyone

Refine high-quality datasets and visual AI models
https://fiftyone.ai
Apache License 2.0
8.85k stars 558 forks source link

[BUG] COCO export format should be 1-indexed #4615

Closed miller-kevin944 closed 1 month ago

miller-kevin944 commented 3 months ago

There is a bug in the export of dates in COCO format. Currently, the category_id keyword in exported labels.json is "0" indexed. However, COCO requires that this be "1" indexed. You can reproduce this, by exporting the quickstart dataset as COCODetectionDataset and searching the labels.json file for "category_id": 0. I haven't checked if this breaks training of models, but it definitely breaks ingest by other computer vision micro services like CVAT if you are not using the SDK to send the jobs directly.

import fiftyone as fo
import fiftyone.zoo as foz
from pathlib import Path

dataset = foz.load_zoo_dataset("quickstart")
dataset.export(
    export_dir=str(Path(__file__).parent.joinpath("coco-example").absolute()),
    dataset_type=fo.types.COCODetectionDataset,
    label_field="ground_truth",
)

image

benjaminpkane commented 3 months ago

Hi @miller-kevin944, we will get this fixed. Thank you for the report 🙇

Duplicates #4570

mythrandire commented 1 month ago

I was able to replicate this too @miller-kevin944. I encountered a similar issue on the data import side of things (#4795), while yours has to do with export formats. Any additional info you can share will be helpful.

brimoor commented 1 month ago

Fixed by https://github.com/voxel51/fiftyone/pull/4884 and will be available in the next fiftyone>1.0 release.