Last active
December 17, 2024 13:26
-
-
Save exminase/92b722a2e9426896230df14567834f4c to your computer and use it in GitHub Desktop.
Hugging Face上のリポジトリのスナップショットを取得するための単純なスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download.py | |
認証が必要なリポジトリを取得する場合は環境変数$HUGGING_FACE_ACCESS_TOKENにAccess Tokenの値を設定してください。 | |
# 初期セットアップ | |
pip install huggingface-hub | |
# 実行方法 | |
python download.py ${repo_id} ${revision_id} | |
例. | |
python download.py openai/whisper-small 358bfe9 | |
# DLしたファイルの保存先 | |
$HOME/.cache/hugging-face/hub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from argparse import ArgumentParser | |
from huggingface_hub import snapshot_download | |
if __name__ == "__main__": | |
parser = ArgumentParser() | |
parser.add_argument("repo_id", type=str, help="Repository ID") | |
parser.add_argument("revision_id", type=str, help="Revision ID") | |
args = parser.parse_args() | |
repo_id = args.repo_id | |
revision_id = args.revision_id | |
access_token = os.environ.get("HUGGING_FACE_ACCESS_TOKEN") | |
print(f"Take a snapshot.\nRepository:{repo_id}, Revision:{revision_id}") | |
if access_token: | |
snapshot_download(repo_id=args.repo_id, revision=args.revision_id, use_auth_token=access_token) | |
else: | |
snapshot_download(repo_id=args.repo_id, revision=args.revision_id) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment