hv-split / push_to_hub.py
zeechimp's picture
Create push_to_hub.py
386f4ba verified
Raw History Blame Contribute Delete
1.29 kB
"""
One-shot upload of hv-split to the Hugging Face Hub.
pip install huggingface_hub
huggingface-cli login
python push_to_hub.py
"""
import os
import tempfile
from huggingface_hub import HfApi, create_repo
from hv_split import HVInterpret
REPO_ID = "zeechimp/hv-split"
def main() -> None:
api = HfApi()
create_repo(REPO_ID, repo_type="model", exist_ok=True)
with tempfile.TemporaryDirectory() as d:
m = HVInterpret()
m.save_pretrained(d)
api.upload_file(
path_or_fileobj=os.path.join(d, "config.json"),
path_in_repo="config.json",
repo_id=REPO_ID,
repo_type="model",
commit_message="Add reference config",
)
for fname in [
"hv_split.py",
"example.py",
"push_to_hub.py",
"README.md",
"requirements.txt",
"LICENSE",
".gitattributes",
]:
if os.path.exists(fname):
api.upload_file(
path_or_fileobj=fname,
path_in_repo=fname,
repo_id=REPO_ID,
repo_type="model",
commit_message=f"Add {fname}",
)
print(f"done. https://huggingface.co/{REPO_ID}")
if __name__ == "__main__":
main()