Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt_download_from_hub, using newly uploaded https://huggingface.co/Ultralytics/YOLOv5/tree/main #261

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions yolov5/utils/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def github_assets(repository, version='latest'):
return response['tag_name'], [x['name'] for x in response['assets']] # tag, assets

# try to download from hf hub
result = attempt_download_from_hub(file, hf_token=hf_token)
result = attempt_download_from_hub(repo, hf_token=hf_token, model_file=file)
if result is not None:
file = result

Expand Down Expand Up @@ -145,7 +145,7 @@ def get_model_filename_from_hfhub(repo_id, hf_token=None):
return None


def attempt_download_from_hub(repo_id, hf_token=None, revision=None):
def attempt_download_from_hub(repo_id, hf_token=None, revision=None, model_file=None):
from huggingface_hub import hf_hub_download, list_repo_files
from huggingface_hub.utils._errors import RepositoryNotFoundError
from huggingface_hub.utils._validators import HFValidationError
Expand All @@ -165,7 +165,8 @@ def attempt_download_from_hub(repo_id, hf_token=None, revision=None):
)

# download model file
model_file = [f for f in repo_files if f.endswith('.pt')][0]
if model_file is None:
model_file = [f for f in repo_files if f.endswith('.pt')][0]
file = hf_hub_download(
repo_id=repo_id,
filename=model_file,
Expand Down
Loading