Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow missing labels for yolo is #18

Merged
merged 5 commits into from
Dec 19, 2024
Merged

Conversation

IgorSusmelj
Copy link
Contributor

Changes

  • This should fix a bug when loading YOLO format labels that have no label files for certain images (.txt files missing)
  • It also resolves a warning that images are not properly freed by using a context manager
  • Also had to update the test to mock the new context manager properly

try:
with label_path.open() as file:
label_data = [line.strip().split() for line in file if line.strip()]
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should never capture all exceptions. Let's be precise and only add the types of exceptions where it's ok to continue.

format=BoundingBoxFormat.CXCYWH,
),
for entry in label_data:
if len(entry) < 5:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if len(entry) < 5:
if len(entry) != 5:

@IgorSusmelj IgorSusmelj merged commit eb11ac3 into main Dec 19, 2024
2 checks passed
@IgorSusmelj IgorSusmelj deleted the allow-missing-labels-for-yolo-is branch December 19, 2024 16:26
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.

2 participants