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:
parent
4e825567a9
commit
4bcc80c646
5 changed files with 12 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = "8.2.100"
|
||||
__version__ = "8.2.101"
|
||||
|
||||
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class Model(nn.Module):
|
|||
# Check if Ultralytics HUB model from https://hub.ultralytics.com
|
||||
if self.is_hub_model(model):
|
||||
# Fetch model from HUB
|
||||
checks.check_requirements("hub-sdk>=0.0.8")
|
||||
checks.check_requirements("hub-sdk>=0.0.12")
|
||||
session = HUBTrainingSession.create_session(model)
|
||||
model = session.model_file
|
||||
if session.train_args: # training sent from HUB
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue