roboflow-python icon indicating copy to clipboard operation
roboflow-python copied to clipboard

fix: support case-insensitive images/labels folders in YOLO datasets

Open Anduin9527 opened this issue 1 month ago • 1 comments

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.

Anduin9527 avatar Oct 13 '25 06:10 Anduin9527

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 26 '25 22:10 CLAassistant