-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Describe the bug
COCO export produces incorrect category handling and incorrect image file paths.
Specifically:
1. COCO export does not respect category ordering / mapping even when category attribute is defined in the labeling config.
2. YOLO export works perfectly with the same project and same labeling config.
3. COCO export with images generates incorrect file_name paths pointing to internal Label Studio storage instead of dataset-relative paths.
To Reproduce
Steps to reproduce the behavior:
- Create a Label Studio project using RectangleLabels.
- Define labels with explicit category attributes in labeling config.
- Export using:
• COCO
• COCO with images
• YOLO (for comparison)
Example labeling config:
<RectangleLabels name="label" toName="image">
<Label value="car" category="1"/>
<Label value="person" category="2"/>
<Label value="truck" category="3"/>
</RectangleLabels>
- Inspect exported JSON.
Observed behavior
❌ Category issues (COCO only)
• COCO export does not respect category mapping defined in config.
• Category IDs appear reordered or reassigned.
• Happens across multiple projects with identical configs.
✅ YOLO Export
• Category mapping and ordering are correct.
• No issues observed.
❌ Image path issue (COCO with images)
COCO export generates:
"file_name": "../../label-studio/data/media/upload/26/6277b484-rsz_1img_9005.jpg"
Instead of something dataset-relative like:
"file_name": "images/6277b484-rsz_1img_9005.jpg"
This makes the dataset harder to use directly for training pipelines and breaks portability.
Observed behavior
Categories
• COCO export should respect category attribute defined in labeling config.
• Category IDs should be stable and predictable across projects when config is identical.
Image Paths
• COCO with images export should use dataset-relative paths.
• Example: images/<filename>.jpg
• Should not reference internal Label Studio storage paths.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: Docker linux
- Label Studio Version: latest - 1.22.0
Additional context
This issue happens consistently across multiple projects with identical labeling configs.
YOLO export works correctly, which suggests the issue is specific to the COCO export pipeline.
This affects downstream ML training because:
• Category mismatch causes incorrect class mapping.
• File path format requires manual post-processing before training.