Skip to content

Conversation

Anduin9527
Copy link

Description

Fix case-sensitive matching issue in YOLO dataset folder parsing. The current implementation only supports lowercase images and labels folders, causing annotation matching to fail when using capitalized folder names like Images and Labels.

Changes

  • Modified _describe_file() in roboflow/util/folderparser.py to use case-insensitive regex replacement instead of hardcoded lowercase string matching
  • Now supports any case variation: images, Images, IMAGES, labels, Labels, LABELS, etc.

Problem

When uploading YOLO format datasets with capitalized folder names (e.g., Train/Images and Train/Labels), the annotation files were not being matched to their corresponding images. This is because the fullkey2 generation used case-sensitive string replacement:

# Before (case-sensitive)
fullkey2 = fullkey.replace("/labels", "").replace("/images", "")

For a path like /Train/Images/image.jpg, the replacement would not match, causing fullkey2 to remain as /train/images/image instead of the expected /train/image.

Solution

Use re.sub() with re.IGNORECASE flag:

# After (case-insensitive)
fullkey2 = re.sub(r"/labels", "", fullkey, flags=re.IGNORECASE)
fullkey2 = re.sub(r"/images", "", fullkey2, flags=re.IGNORECASE)

Testing

Verified that:

  • Images with annotations in capitalized folders (Images/Labels) are now correctly matched
  • Existing lowercase folder structures continue to work as before
  • Upload process shows annotations = OK for all images

Related Issues

Fixes the issue where YOLO datasets with non-lowercase folder names fail to upload annotations.

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.

1 participant