ultralytics 8.1.2 scope HUB-SDK imports (#7596)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-01-15 23:48:20 +01:00 committed by GitHub
parent b1282544d2
commit 5f5f5d08f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 20 deletions

View File

@ -78,7 +78,6 @@ dependencies = [
"thop>=0.1.1", # FLOPs computation "thop>=0.1.1", # FLOPs computation
"pandas>=1.1.4", "pandas>=1.1.4",
"seaborn>=0.11.0", # plotting "seaborn>=0.11.0", # plotting
"hub-sdk>=0.0.2", # Ultralytics HUB
] ]
# Optional dependencies ------------------------------------------------------------------------------------------------ # Optional dependencies ------------------------------------------------------------------------------------------------
@ -103,13 +102,11 @@ export = [
"tensorflow<=2.13.1", # TF bug https://github.com/ultralytics/ultralytics/issues/5161 "tensorflow<=2.13.1", # TF bug https://github.com/ultralytics/ultralytics/issues/5161
"tensorflowjs>=3.9.0", # TF.js export, automatically installs tensorflow "tensorflowjs>=3.9.0", # TF.js export, automatically installs tensorflow
] ]
explorer = [ explorer = [
"lancedb", # vector search "lancedb", # vector search
"duckdb", # SQL queries, supports lancedb tables "duckdb", # SQL queries, supports lancedb tables
"streamlit", # visualizing with GUI "streamlit", # visualizing with GUI
] ]
# tensorflow>=2.4.1,<=2.13.1 # TF exports (-cpu, -aarch64, -macos) # tensorflow>=2.4.1,<=2.13.1 # TF exports (-cpu, -aarch64, -macos)
# tflite-support # for TFLite model metadata # tflite-support # for TFLite model metadata
# scikit-learn==0.19.2 # CoreML quantization # scikit-learn==0.19.2 # CoreML quantization
@ -121,6 +118,7 @@ logging = [
"dvclive>=2.12.0", "dvclive>=2.12.0",
] ]
extra = [ extra = [
"hub-sdk>=0.0.2", # Ultralytics HUB
"ipython", # interactive notebook "ipython", # interactive notebook
"albumentations>=1.0.3", # training augmentations "albumentations>=1.0.3", # training augmentations
"pycocotools>=2.0.6", # COCO mAP "pycocotools>=2.0.6", # COCO mAP

View File

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.1.1" __version__ = "8.1.2"
from ultralytics.data.explorer.explorer import Explorer from ultralytics.data.explorer.explorer import Explorer
from ultralytics.models import RTDETR, SAM, YOLO from ultralytics.models import RTDETR, SAM, YOLO

View File

@ -5,11 +5,10 @@ import sys
from pathlib import Path from pathlib import Path
from typing import Union from typing import Union
from hub_sdk.config import HUB_WEB_ROOT
from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir 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.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.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): 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 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(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): def _new(self, cfg: str, task=None, model=None, verbose=True):
""" """

View File

@ -1,12 +1,11 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
import requests import requests
from hub_sdk import HUB_API_ROOT, HUB_WEB_ROOT, HUBClient
from ultralytics.data.utils import HUBDatasetStats from ultralytics.data.utils import HUBDatasetStats
from ultralytics.hub.auth import Auth from ultralytics.hub.auth import Auth
from ultralytics.hub.utils import PREFIX from ultralytics.hub.utils import HUB_API_ROOT, HUB_WEB_ROOT, PREFIX
from ultralytics.utils import LOGGER, SETTINGS from ultralytics.utils import LOGGER, SETTINGS, checks
def login(api_key: str = None, save=True) -> bool: def login(api_key: str = None, save=True) -> bool:
@ -21,6 +20,9 @@ def login(api_key: str = None, save=True) -> bool:
Returns: Returns:
bool: True if authentication is successful, False otherwise. 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 api_key_url = f"{HUB_WEB_ROOT}/settings?tab=api+keys" # set the redirect URL
saved_key = SETTINGS.get("api_key") saved_key = SETTINGS.get("api_key")
active_key = api_key or saved_key active_key = api_key or saved_key

View File

@ -1,9 +1,8 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
import requests 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 from ultralytics.utils import LOGGER, SETTINGS, emojis, is_colab
API_KEY_URL = f"{HUB_WEB_ROOT}/settings?tab=api+keys" API_KEY_URL = f"{HUB_WEB_ROOT}/settings?tab=api+keys"

View File

@ -6,9 +6,8 @@ from http import HTTPStatus
from pathlib import Path from pathlib import Path
import requests 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 import LOGGER, SETTINGS, __version__, checks, emojis, is_colab
from ultralytics.utils.errors import HUBModelError from ultralytics.utils.errors import HUBModelError
@ -44,6 +43,9 @@ class HUBTrainingSession:
ValueError: If the provided model identifier is invalid. ValueError: If the provided model identifier is invalid.
ConnectionError: If connecting with global API key is not supported. 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 = { self.rate_limits = {
"metrics": 3.0, "metrics": 3.0,
"ckpt": 900.0, "ckpt": 900.0,
@ -70,8 +72,8 @@ class HUBTrainingSession:
def load_model(self, model_id): def load_model(self, model_id):
"""Loads an existing model from Ultralytics HUB using the provided model identifier.""" """Loads an existing model from Ultralytics HUB using the provided model identifier."""
self.model = self.client.model(model_id) self.model = self.client.model(model_id)
if not self.model.data: # then model model does not exist if not self.model.data: # then model does not exist
raise ValueError(emojis(f"❌ The specified HUB model does not exist")) # TODO: improve error handling 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}" self.model_url = f"{HUB_WEB_ROOT}/models/{self.model.id}"

View File

@ -1,5 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
import os
import platform import platform
import random import random
import sys import sys
@ -27,6 +28,9 @@ from ultralytics.utils import (
) )
from ultralytics.utils.downloads import GITHUB_ASSETS_NAMES 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: ") PREFIX = colorstr("Ultralytics HUB: ")
HELP_MSG = "If this issue persists please visit https://github.com/ultralytics/hub/issues for assistance." HELP_MSG = "If this issue persists please visit https://github.com/ultralytics/hub/issues for assistance."

View File

@ -3,9 +3,7 @@
import json import json
from time import time from time import time
from hub_sdk.config import HUB_WEB_ROOT from ultralytics.hub.utils import HUB_WEB_ROOT, PREFIX, events
from ultralytics.hub.utils import PREFIX, events
from ultralytics.utils import LOGGER, SETTINGS from ultralytics.utils import LOGGER, SETTINGS