zeechimp commited on
Commit
0f9ea90
·
verified ·
1 Parent(s): a203ab2

Create push_to_hub.py

Browse files
Files changed (1) hide show
  1. push_to_hub.py +45 -0
push_to_hub.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Push hv-reader to the Hugging Face Hub."""
2
+ import os
3
+
4
+ from huggingface_hub import HfApi, create_repo
5
+
6
+ from hv_reader import HVReader
7
+
8
+ REPO_ID = "zeechimp/hv-reader"
9
+
10
+
11
+ def main() -> None:
12
+ api = HfApi()
13
+ create_repo(REPO_ID, repo_type="model", exist_ok=True)
14
+
15
+ model = HVReader()
16
+ model.save_pretrained("./hv_reader_model")
17
+
18
+ api.upload_folder(
19
+ folder_path="./hv_reader_model",
20
+ repo_id=REPO_ID,
21
+ path_in_repo=".",
22
+ commit_message="Upload hv-reader config",
23
+ )
24
+
25
+ for fname in [
26
+ "hv_reader.py", "app.py", "example.py", "push_to_hub.py",
27
+ "README.md", "requirements.txt", "LICENSE", ".gitattributes",
28
+ ]:
29
+ if not os.path.exists(fname):
30
+ print(f" skip (missing): {fname}")
31
+ continue
32
+ api.upload_file(
33
+ path_or_fileobj=fname,
34
+ path_in_repo=fname,
35
+ repo_id=REPO_ID,
36
+ commit_message=f"Upload {fname}",
37
+ )
38
+ print(f" uploaded: {fname}")
39
+
40
+ print()
41
+ print(f"pushed to https://huggingface.co/{REPO_ID}")
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()