ultralytics 8.2.101 allow HUB public model downloads (#16488)

Signed-off-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-09-25 15:17:25 +02:00 committed by GitHub
parent 4e825567a9
commit 4bcc80c646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 12 additions and 10 deletions

View file

@ -38,7 +38,7 @@ 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.8")
checks.check_requirements("hub-sdk>=0.0.12")
from hub_sdk import HUBClient
api_key_url = f"{HUB_WEB_ROOT}/settings?tab=api+keys" # set the redirect URL

View file

@ -63,22 +63,24 @@ class HUBTrainingSession:
# Initialize client
self.client = HUBClient(credentials)
# Load models if authenticated
if self.client.authenticated:
# Load models
try:
if model_id:
self.load_model(model_id) # load existing model
else:
self.model = self.client.model() # load empty model
except Exception:
if identifier.startswith(f"{HUB_WEB_ROOT}/models/") and not self.client.authenticated:
LOGGER.warning(
f"{PREFIX}WARNING ⚠️ Please log in using 'yolo login API_KEY'. "
"You can find your API Key at: https://hub.ultralytics.com/settings?tab=api+keys."
)
@classmethod
def create_session(cls, identifier, args=None):
"""Class method to create an authenticated HUBTrainingSession or return None."""
try:
session = cls(identifier)
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'.")
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"