Avoid creating -hub dir without processing images (#8334)

This commit is contained in:
Glenn Jocher 2024-02-20 17:27:28 +01:00 committed by GitHub
parent 61088b43d7
commit d03928f371
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -467,7 +467,6 @@ class HUBDatasetStats:
self.hub_dir = Path(f'{data["path"]}-hub')
self.im_dir = self.hub_dir / "images"
self.im_dir.mkdir(parents=True, exist_ok=True) # makes /images
self.stats = {"nc": len(data["names"]), "names": list(data["names"].values())} # statistics dictionary
self.data = data
@ -551,6 +550,7 @@ class HUBDatasetStats:
# Save, print and return
if save:
self.hub_dir.mkdir(parents=True, exist_ok=True) # makes dataset-hub/
stats_path = self.hub_dir / "stats.json"
LOGGER.info(f"Saving {stats_path.resolve()}...")
with open(stats_path, "w") as f:
@ -563,6 +563,7 @@ class HUBDatasetStats:
"""Compress images for Ultralytics HUB."""
from ultralytics.data import YOLODataset # ClassificationDataset
self.im_dir.mkdir(parents=True, exist_ok=True) # makes dataset-hub/images/
for split in "train", "val", "test":
if self.data.get(split) is None:
continue