Skip to content

Conversation

iurisilvio
Copy link
Contributor

@iurisilvio iurisilvio commented Oct 5, 2025

Description

Fix annotation imports with inconsistent image file names or with images in subfolders.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

Added a test to validate the scenario.


Note

Improves folder parsing to reliably match annotations to images (including COCO with subdirectory file_names), and adds tests for these cases.

  • Util: roboflow/util/folderparser.py
    • Annotation→Image mapping overhaul:
      • Matches using image relative path, basename, or stem; falls back to all annotation files when needed.
      • Adds _build_image_to_annotationfile_index supporting coco, createml, csv, multilabel_csv, and jsonl.
      • Enhances COCO handling by normalizing paths and indexing by full path/basename/stem; fixes root-annotation ↔ subdir-image mismatches.
      • Updates _filterIndividualAnnotations to try multiple keys (rel path → basename → stem) and corrects annotation map lookup keys.
  • Tests: tests/util/test_folderparser.py
    • Adds tests verifying COCO annotations at root match images in subdirectories and images referenced with subdir file_name match root-level images.
  • Version: bump __version__ to 1.2.11.

Written by Cursor Bugbot for commit 76ae33f. This will update automatically on new commits. Configure here.

@iurisilvio iurisilvio self-assigned this Oct 6, 2025
or image_path_to_annotation_files.get(image["name"], [])
or image_path_to_annotation_files.get(image["key"], [])
or annotationFiles # Fallback to all files for non-COCO formats
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Fallback Annotation Mapping Causes Inefficiency

The _map_annotations_to_images_1tomany function includes a fallback to annotationFiles that causes images to be checked against all annotation files if the index yields no specific matches. This can lead to inefficient processing and potentially incorrect annotation assignments, as images might be matched to unrelated files.

Fix in Cursor Fix in Web

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ iurisilvio
❌ pre-commit-ci[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants