ultralytics 8.2.97 robust HUB model downloads (#16347)
Signed-off-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
7834d19776
commit
6dcc4a0610
4 changed files with 29 additions and 46 deletions
|
|
@ -206,33 +206,21 @@ class Model(nn.Module):
|
|||
Check if the provided model is an Ultralytics HUB model.
|
||||
|
||||
This static method determines whether the given model string represents a valid Ultralytics HUB model
|
||||
identifier. It checks for three possible formats: a full HUB URL, an API key and model ID combination,
|
||||
or a standalone model ID.
|
||||
identifier.
|
||||
|
||||
Args:
|
||||
model (str): The model identifier to check. This can be a URL, an API key and model ID
|
||||
combination, or a standalone model ID.
|
||||
model (str): The model string to check.
|
||||
|
||||
Returns:
|
||||
(bool): True if the model is a valid Ultralytics HUB model, False otherwise.
|
||||
|
||||
Examples:
|
||||
>>> Model.is_hub_model("https://hub.ultralytics.com/models/example_model")
|
||||
>>> Model.is_hub_model("https://hub.ultralytics.com/models/MODEL")
|
||||
True
|
||||
>>> Model.is_hub_model("api_key_example_model_id")
|
||||
True
|
||||
>>> Model.is_hub_model("example_model_id")
|
||||
True
|
||||
>>> Model.is_hub_model("not_a_hub_model.pt")
|
||||
>>> Model.is_hub_model("yolov8n.pt")
|
||||
False
|
||||
"""
|
||||
return any(
|
||||
(
|
||||
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_MODEL
|
||||
len(model) == 20 and not Path(model).exists() and all(x not in model for x in "./\\"), # MODEL
|
||||
)
|
||||
)
|
||||
return model.startswith(f"{HUB_WEB_ROOT}/models/")
|
||||
|
||||
def _new(self, cfg: str, task=None, model=None, verbose=False) -> None:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue