diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 5be255eb..a85ed8ee 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.2.40" +__version__ = "8.2.41" import os diff --git a/ultralytics/hub/session.py b/ultralytics/hub/session.py index 369df744..41fe8c6d 100644 --- a/ultralytics/hub/session.py +++ b/ultralytics/hub/session.py @@ -71,7 +71,11 @@ class HUBTrainingSession: """Class method to create an authenticated HUBTrainingSession or return None.""" try: session = cls(identifier) - assert session.client.authenticated, "HUB not authenticated" + if not session.client.authenticated: + if identifier.startswith(f"{HUB_WEB_ROOT}/models/"): + LOGGER.warning(f"{PREFIX}WARNING ⚠️ Login to Ultralytics HUB with 'yolo hub login API_KEY'.") + exit() + return None if args and not identifier.startswith(f"{HUB_WEB_ROOT}/models/"): # not a HUB model URL session.create_model(args) assert session.model.id, "HUB model not loaded correctly" diff --git a/ultralytics/utils/downloads.py b/ultralytics/utils/downloads.py index 757f7e50..ab7ffa08 100644 --- a/ultralytics/utils/downloads.py +++ b/ultralytics/utils/downloads.py @@ -168,13 +168,15 @@ def unzip_file(file, path=None, exclude=(".DS_Store", "__MACOSX"), exist_ok=Fals files = [f for f in zipObj.namelist() if all(x not in f for x in exclude)] top_level_dirs = {Path(f).parts[0] for f in files} - if len(top_level_dirs) > 1 or (len(files) > 1 and not files[0].endswith("/")): - # Zip has multiple files at top level - path = extract_path = Path(path) / Path(file).stem # i.e. ../datasets/coco8 - else: + # Decide to unzip directly or unzip into a directory + unzip_as_dir = len(top_level_dirs) == 1 # (len(files) > 1 and not files[0].endswith("/")) + if unzip_as_dir: # Zip has 1 top-level directory extract_path = path # i.e. ../datasets - path = Path(path) / list(top_level_dirs)[0] # i.e. ../datasets/coco8 + path = Path(path) / list(top_level_dirs)[0] # i.e. extract coco8/ dir to ../datasets/ + else: + # Zip has multiple files at top level + path = extract_path = Path(path) / Path(file).stem # i.e. extract multiple files to ../datasets/coco8/ # Check if destination directory already exists and contains files if path.exists() and any(path.iterdir()) and not exist_ok: