File size: 1,285 Bytes
386f4ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
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()