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

simplify the way to load annotation file #3524

Closed
wants to merge 1 commit into from

Conversation

developer0hye
Copy link
Contributor

@developer0hye developer0hye commented Jun 8, 2021

simplify the way to load annotation file

@glenn-jocher

How about this way in terms of readability?

The below code is simple example code.

import numpy as np

gt_file = np.array([[0, 0.5, 0.5, 0.5, 0.5],
                   [1, 0.5, 0.5, 0.5, 0.5]]).reshape(-1, 5)

np.savetxt("gt_file.txt", gt_file)

gt_file = np.loadtxt("gt_file.txt", dtype=np.float32).reshape(-1, 5)

print(gt_file)

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Simplified label loading process in YOLOv5 datasets.

📊 Key Changes

  • Removed complex label parsing logic with multiple condition checks.
  • Replaced with a streamlined np.loadtxt for direct reading and reshaping of label files.

🎯 Purpose & Impact

  • Purpose: To streamline the process of loading labels for images, making the codebase simpler and potentially faster.
  • Impact: Users should experience more efficient label loading with fewer opportunities for errors during the label verification process. 🚀

simplify the way to load annotation file
@developer0hye
Copy link
Contributor Author

image

It is very slow...

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 8, 2021

@developer0hye yes reading label text files is pretty slow. Label text files can be of two formats:

Box labels

class x y w h
class x y w h
...

Segment labels (can be any number of segment points > 4, different rows can be different length)

class xy0 xy1 xy2 xy3 xy4  # minimum 9 columns
class xy0 xy1 xy2 xy3 xy4 xy5 xy6 ...  # no maximum columns
...

@developer0hye
Copy link
Contributor Author

@glenn-jocher

Ah, okay. Original one is better than this!

@glenn-jocher
Copy link
Member

@developer0hye well I don't know, if there's a faster way to load and parse the data depending on the column count then that would be great.

@yeldarby yeldarby mentioned this pull request Mar 10, 2022
1 task
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.

None yet

2 participants