diff --git a/pyproject.toml b/pyproject.toml index f4a35493..6188b322 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,6 @@ dependencies = [ "thop>=0.1.1", # FLOPs computation "pandas>=1.1.4", "seaborn>=0.11.0", # plotting - "hub-sdk>=0.0.2", # Ultralytics HUB ] # Optional dependencies ------------------------------------------------------------------------------------------------ @@ -103,13 +102,11 @@ export = [ "tensorflow<=2.13.1", # TF bug https://github.com/ultralytics/ultralytics/issues/5161 "tensorflowjs>=3.9.0", # TF.js export, automatically installs tensorflow ] - explorer = [ "lancedb", # vector search "duckdb", # SQL queries, supports lancedb tables "streamlit", # visualizing with GUI ] - # tensorflow>=2.4.1,<=2.13.1 # TF exports (-cpu, -aarch64, -macos) # tflite-support # for TFLite model metadata # scikit-learn==0.19.2 # CoreML quantization @@ -121,6 +118,7 @@ logging = [ "dvclive>=2.12.0", ] extra = [ + "hub-sdk>=0.0.2", # Ultralytics HUB "ipython", # interactive notebook "albumentations>=1.0.3", # training augmentations "pycocotools>=2.0.6", # COCO mAP diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index ca09cf93..650d3c5d 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.1.1" +__version__ = "8.1.2" from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import RTDETR, SAM, YOLO diff --git a/ultralytics/engine/model.py b/ultralytics/engine/model.py index 7e899d8b..4916356b 100644 --- a/ultralytics/engine/model.py +++ b/ultralytics/engine/model.py @@ -5,11 +5,10 @@ import sys from pathlib import Path from typing import Union -from hub_sdk.config import HUB_WEB_ROOT - from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task, nn, yaml_model_load from ultralytics.utils import ASSETS, DEFAULT_CFG_DICT, LOGGER, RANK, SETTINGS, callbacks, checks, emojis, yaml_load +from ultralytics.hub.utils import HUB_WEB_ROOT class Model(nn.Module): @@ -123,9 +122,9 @@ class Model(nn.Module): ( model.startswith(f"{HUB_WEB_ROOT}/models/"), # i.e. https://hub.ultralytics.com/models/MODEL_ID [len(x) for x in model.split("_")] == [42, 20], # APIKEY_MODELID - len(model) == 20 and not Path(model).exists() and all(x not in model for x in "./\\"), + len(model) == 20 and not Path(model).exists() and all(x not in model for x in "./\\"), # MODELID ) - ) # MODELID + ) def _new(self, cfg: str, task=None, model=None, verbose=True): """ diff --git a/ultralytics/hub/__init__.py b/ultralytics/hub/__init__.py index df17da5e..745d4a94 100644 --- a/ultralytics/hub/__init__.py +++ b/ultralytics/hub/__init__.py @@ -1,12 +1,11 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license import requests -from hub_sdk import HUB_API_ROOT, HUB_WEB_ROOT, HUBClient from ultralytics.data.utils import HUBDatasetStats from ultralytics.hub.auth import Auth -from ultralytics.hub.utils import PREFIX -from ultralytics.utils import LOGGER, SETTINGS +from ultralytics.hub.utils import HUB_API_ROOT, HUB_WEB_ROOT, PREFIX +from ultralytics.utils import LOGGER, SETTINGS, checks def login(api_key: str = None, save=True) -> bool: @@ -21,6 +20,9 @@ def login(api_key: str = None, save=True) -> bool: Returns: bool: True if authentication is successful, False otherwise. """ + checks.check_requirements("hub-sdk>=0.0.2") + from hub_sdk import HUBClient + api_key_url = f"{HUB_WEB_ROOT}/settings?tab=api+keys" # set the redirect URL saved_key = SETTINGS.get("api_key") active_key = api_key or saved_key diff --git a/ultralytics/hub/auth.py b/ultralytics/hub/auth.py index 72aad109..17bb4986 100644 --- a/ultralytics/hub/auth.py +++ b/ultralytics/hub/auth.py @@ -1,9 +1,8 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license import requests -from hub_sdk import HUB_API_ROOT, HUB_WEB_ROOT -from ultralytics.hub.utils import PREFIX, request_with_credentials +from ultralytics.hub.utils import HUB_API_ROOT, HUB_WEB_ROOT, PREFIX, request_with_credentials from ultralytics.utils import LOGGER, SETTINGS, emojis, is_colab API_KEY_URL = f"{HUB_WEB_ROOT}/settings?tab=api+keys" diff --git a/ultralytics/hub/session.py b/ultralytics/hub/session.py index aa5d2f8b..bc01bf55 100644 --- a/ultralytics/hub/session.py +++ b/ultralytics/hub/session.py @@ -6,9 +6,8 @@ from http import HTTPStatus from pathlib import Path import requests -from hub_sdk import HUB_WEB_ROOT, HUBClient -from ultralytics.hub.utils import HELP_MSG, PREFIX, TQDM +from ultralytics.hub.utils import HUB_WEB_ROOT, HELP_MSG, PREFIX, TQDM from ultralytics.utils import LOGGER, SETTINGS, __version__, checks, emojis, is_colab from ultralytics.utils.errors import HUBModelError @@ -44,6 +43,9 @@ class HUBTrainingSession: ValueError: If the provided model identifier is invalid. ConnectionError: If connecting with global API key is not supported. """ + checks.check_requirements("hub-sdk>=0.0.2") + from hub_sdk import HUBClient + self.rate_limits = { "metrics": 3.0, "ckpt": 900.0, @@ -70,8 +72,8 @@ class HUBTrainingSession: def load_model(self, model_id): """Loads an existing model from Ultralytics HUB using the provided model identifier.""" self.model = self.client.model(model_id) - if not self.model.data: # then model model does not exist - raise ValueError(emojis(f"❌ The specified HUB model does not exist")) # TODO: improve error handling + if not self.model.data: # then model does not exist + raise ValueError(emojis("❌ The specified HUB model does not exist")) # TODO: improve error handling self.model_url = f"{HUB_WEB_ROOT}/models/{self.model.id}" diff --git a/ultralytics/hub/utils.py b/ultralytics/hub/utils.py index 2cdd0350..e870fada 100644 --- a/ultralytics/hub/utils.py +++ b/ultralytics/hub/utils.py @@ -1,5 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license +import os import platform import random import sys @@ -27,6 +28,9 @@ from ultralytics.utils import ( ) from ultralytics.utils.downloads import GITHUB_ASSETS_NAMES +HUB_API_ROOT = os.environ.get("ULTRALYTICS_HUB_API", "https://api.ultralytics.com") +HUB_WEB_ROOT = os.environ.get("ULTRALYTICS_HUB_WEB", "https://hub.ultralytics.com") + PREFIX = colorstr("Ultralytics HUB: ") HELP_MSG = "If this issue persists please visit https://github.com/ultralytics/hub/issues for assistance." diff --git a/ultralytics/utils/callbacks/hub.py b/ultralytics/utils/callbacks/hub.py index 60c74161..6002431a 100644 --- a/ultralytics/utils/callbacks/hub.py +++ b/ultralytics/utils/callbacks/hub.py @@ -3,9 +3,7 @@ import json from time import time -from hub_sdk.config import HUB_WEB_ROOT - -from ultralytics.hub.utils import PREFIX, events +from ultralytics.hub.utils import HUB_WEB_ROOT, PREFIX, events from ultralytics.utils import LOGGER, SETTINGS