zeechimp commited on
Commit
386f4ba
·
verified ·
1 Parent(s): 76a4c0e

Create push_to_hub.py

Browse files
Files changed (1) hide show
  1. push_to_hub.py +57 -0
push_to_hub.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ One-shot upload of hv-split to the Hugging Face Hub.
3
+
4
+ pip install huggingface_hub
5
+ huggingface-cli login
6
+ python push_to_hub.py
7
+ """
8
+
9
+ import os
10
+ import tempfile
11
+
12
+ from huggingface_hub import HfApi, create_repo
13
+
14
+ from hv_split import HVInterpret
15
+
16
+
17
+ REPO_ID = "zeechimp/hv-split"
18
+
19
+
20
+ def main() -> None:
21
+ api = HfApi()
22
+ create_repo(REPO_ID, repo_type="model", exist_ok=True)
23
+
24
+ with tempfile.TemporaryDirectory() as d:
25
+ m = HVInterpret()
26
+ m.save_pretrained(d)
27
+ api.upload_file(
28
+ path_or_fileobj=os.path.join(d, "config.json"),
29
+ path_in_repo="config.json",
30
+ repo_id=REPO_ID,
31
+ repo_type="model",
32
+ commit_message="Add reference config",
33
+ )
34
+
35
+ for fname in [
36
+ "hv_split.py",
37
+ "example.py",
38
+ "push_to_hub.py",
39
+ "README.md",
40
+ "requirements.txt",
41
+ "LICENSE",
42
+ ".gitattributes",
43
+ ]:
44
+ if os.path.exists(fname):
45
+ api.upload_file(
46
+ path_or_fileobj=fname,
47
+ path_in_repo=fname,
48
+ repo_id=REPO_ID,
49
+ repo_type="model",
50
+ commit_message=f"Add {fname}",
51
+ )
52
+
53
+ print(f"done. https://huggingface.co/{REPO_ID}")
54
+
55
+
56
+ if __name__ == "__main__":
57
+ main()