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

New HUBDatasetStats() class #8716

Merged
merged 10 commits into from
Jul 25, 2022
Merged

New HUBDatasetStats() class #8716

merged 10 commits into from
Jul 25, 2022

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jul 25, 2022

Usage examples:

from utils.dataloaders import HUBDatasetStats

stats = HUBDatasetStats('coco128.yaml', autodownload=True)  # method 1
stats = HUBDatasetStats('path/to/coco128_with_yaml.zip')  # method 2

stats_json = stats.get_json(save=False)
im_dir = stats.process_images()

@kalenmike

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Refactored dataset statistics calculation and image processing in yolov5.

📊 Key Changes

  • Introduced HUBDatasetStats class for dataset statistics and image processing.
  • Moved various functions into the class as methods, including _unzip, _hub_ops, and _find_yaml.
  • Added __init__ method to initialize class with paths and dataset verification.
  • Added get_json method to compute and optionally save dataset statistics.
  • Added process_images method to compress and save images for Ultralytics HUB.
  • Streamlined logic by encapsulating functionality and improving code organization.

🎯 Purpose & Impact

  • The new class-based approach organizes functionality better and simplifies the codebase.
  • Provides a more maintainable and extendable structure for future enhancements.
  • Impact on users includes potentially improved efficiency, reliability, and usability when dealing with dataset statistics and preparing images for Ultralytics HUB.

Usage examples:
```
from utils.dataloaders import *

stats = HUBDatasetStats('coco128.yaml', autodownload=True)  # method 1
stats = HUBDatasetStats('path/to/coco128_with_yaml.zip')  # method 1

stats.get_json(save=False)
stats.process_images()
```

@kalenmike
@glenn-jocher glenn-jocher self-assigned this Jul 25, 2022
@glenn-jocher glenn-jocher merged commit b367860 into master Jul 25, 2022
@glenn-jocher glenn-jocher deleted the update/hub_ops branch July 25, 2022 16:20
@glenn-jocher
Copy link
Member Author

@kalenmike PR is merged

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* New `HUBDatasetStats()` class

Usage examples:
```
from utils.dataloaders import *

stats = HUBDatasetStats('coco128.yaml', autodownload=True)  # method 1
stats = HUBDatasetStats('path/to/coco128_with_yaml.zip')  # method 1

stats.get_json(save=False)
stats.process_images()
```

@kalenmike

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dataloaders.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dataloaders.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dataloaders.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dataloaders.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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