zeechimp commited on
Commit
6bf15c4
·
verified ·
1 Parent(s): e97c4e0

Create push_to_hub.py

Browse files
Files changed (1) hide show
  1. push_to_hub.py +56 -0
push_to_hub.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Push hv-core to the Hugging Face Hub."""
2
+ import os
3
+
4
+ from huggingface_hub import HfApi, create_repo
5
+
6
+ from hv_core import HVCore
7
+
8
+ REPO_ID = "zeechimp/hv-core"
9
+
10
+
11
+ def main() -> None:
12
+ api = HfApi()
13
+
14
+ # Create the repo if it doesn't exist
15
+ create_repo(REPO_ID, repo_type="model", exist_ok=True)
16
+
17
+ # Save model config locally
18
+ model = HVCore()
19
+ model.save_pretrained("./hv_core_model")
20
+
21
+ # Upload the saved config folder
22
+ api.upload_folder(
23
+ folder_path="./hv_core_model",
24
+ repo_id=REPO_ID,
25
+ path_in_repo=".",
26
+ commit_message="Upload hv-core config",
27
+ )
28
+
29
+ # Upload the source + supporting files
30
+ for fname in [
31
+ "hv_core.py",
32
+ "app.py",
33
+ "example.py",
34
+ "push_to_hub.py",
35
+ "README.md",
36
+ "requirements.txt",
37
+ "LICENSE",
38
+ ".gitattributes",
39
+ ]:
40
+ if not os.path.exists(fname):
41
+ print(f" skip (missing): {fname}")
42
+ continue
43
+ api.upload_file(
44
+ path_or_fileobj=fname,
45
+ path_in_repo=fname,
46
+ repo_id=REPO_ID,
47
+ commit_message=f"Upload {fname}",
48
+ )
49
+ print(f" uploaded: {fname}")
50
+
51
+ print()
52
+ print(f"pushed to https://huggingface.co/{REPO_ID}")
53
+
54
+
55
+ if __name__ == "__main__":
56
+ main()