`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>
pull/7608/head v8.1.2
Glenn Jocher 1 year ago committed by GitHub
parent b1282544d2
commit 5f5f5d08f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pyproject.toml
  2. 2
      ultralytics/__init__.py
  3. 7
      ultralytics/engine/model.py
  4. 8
      ultralytics/hub/__init__.py
  5. 3
      ultralytics/hub/auth.py
  6. 10
      ultralytics/hub/session.py
  7. 4
      ultralytics/hub/utils.py
  8. 4
      ultralytics/utils/callbacks/hub.py

@ -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

@ -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

@ -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):
"""

@ -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

@ -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"

@ -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}"

@ -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."

@ -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

Loading…
Cancel
Save