File size: 1,218 Bytes
013f05c 002c29c 013f05c 027276a 013f05c 6059fae 013f05c 002c29c 013f05c 6059fae 002c29c 6059fae 002c29c 027276a 013f05c 002c29c 77d904f 013f05c 6059fae 90643e4 6059fae 6db277e 6059fae e051941 af15041 845d0b8 e051941 af15041 e051941 002c29c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import os
from pathlib import Path
from huggingface_hub import (
HfApi,
Repository,
create_repo,
get_full_repo_name,
hf_hub_download,
login,
logout,
snapshot_download,
upload_file,
)
repo_name = "test2"
repo_dir = Path("hfhub")
token = os.environ["HF_TOKEN"]
download_checkpoint_with_name = "test_checkpoint"
(Path(repo_dir) / "checkpoints").mkdir(parents=True, exist_ok=True)
login(token=token)
hf_api = HfApi(token=token)
# username/repo_name
repo_name = get_full_repo_name(repo_name)
repo_url = create_repo(
repo_id=repo_name, repo_type="model", exist_ok=True, private=True
)
upload_file(
repo_id=repo_name,
repo_type="model",
path_or_fileobj="hfhub.py",
path_in_repo="hfhub.py",
)
ckpt_filepath = hf_hub_download(
repo_id=repo_name,
repo_type="model",
# cache_dir=Path(repo_dir),
resume_download=True,
# subfolder="checkpoints",
filename="hfhub.py",
local_dir=Path(repo_dir) / "checkpoints",
)
print(ckpt_filepath)
snapshot_download(
repo_id="kiyoonkim/hmdb51-gulprgb",
repo_type="dataset",
resume_download=True,
local_dir=Path(repo_dir) / "datasets",
allow_patterns="splits_gulp_rgb/*",
)
logout()
|