Skip to content

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.

2 participants