Enzo8930302 commited on
Commit
0837576
·
verified ·
1 Parent(s): 059e0d4

Upload publish_to_hf.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. publish_to_hf.py +64 -20
publish_to_hf.py CHANGED
@@ -1,30 +1,74 @@
1
  """
2
  Upload Byte Dream to Hugging Face Hub
3
- Using login() and upload_folder() methods
4
  """
5
 
6
  import os
7
- from huggingface_hub import login, upload_folder
8
-
9
- # Get token from command line argument or prompt
10
  import sys
 
11
 
12
- if len(sys.argv) > 1:
13
- token = sys.argv[1]
14
- else:
15
- token = input("Enter your Hugging Face token: ")
16
 
17
- # Login with your Hugging Face token
18
- print("Logging in to Hugging Face...")
19
- login(token=token)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- # Push your model files
22
- print("\nUploading model to Hugging Face Hub...")
23
- upload_folder(
24
- folder_path=".",
25
- repo_id="Enzo8930302/ByteDream",
26
- repo_type="model"
27
- )
28
 
29
- print("\n✓ Model uploaded successfully!")
30
- print("📦 View your model at: https://huggingface.co/Enzo8930302/ByteDream")
 
1
  """
2
  Upload Byte Dream to Hugging Face Hub
3
+ Using the new push_to_hub API from generator
4
  """
5
 
6
  import os
 
 
 
7
  import sys
8
+ from pathlib import Path
9
 
 
 
 
 
10
 
11
+ def main():
12
+ # Get token from command line argument or prompt
13
+ if len(sys.argv) > 1:
14
+ token = sys.argv[1]
15
+ else:
16
+ token = input("Enter your Hugging Face token: ")
17
+
18
+ # Get repo ID
19
+ if len(sys.argv) > 2:
20
+ repo_id = sys.argv[2]
21
+ else:
22
+ repo_id = input("Enter repository ID (e.g., username/ByteDream): ")
23
+
24
+ # Check if model exists, if not train first
25
+ model_path = Path("./models/bytedream")
26
+ if not model_path.exists():
27
+ print("\n⚠ Model directory not found!")
28
+ print("Please train the model first using: python train.py")
29
+ print("Or download pretrained weights.")
30
+ sys.exit(1)
31
+
32
+ print("\n" + "="*60)
33
+ print("Byte Dream - Upload to Hugging Face Hub")
34
+ print("="*60)
35
+
36
+ try:
37
+ # Import generator
38
+ from bytedream.generator import ByteDreamGenerator
39
+
40
+ # Initialize generator with trained model
41
+ print("\nLoading model...")
42
+ generator = ByteDreamGenerator(
43
+ model_path="./models/bytedream",
44
+ config_path="config.yaml",
45
+ device="cpu",
46
+ )
47
+
48
+ # Push to Hub
49
+ print(f"\nUploading to {repo_id}...")
50
+ generator.push_to_hub(
51
+ repo_id=repo_id,
52
+ token=token,
53
+ private=False,
54
+ commit_message="Upload Byte Dream model",
55
+ )
56
+
57
+ print("\n" + "="*60)
58
+ print("✓ SUCCESS!")
59
+ print("="*60)
60
+ print(f"\n📦 Your model is available at:")
61
+ print(f"https://huggingface.co/{repo_id}")
62
+ print("\nTo use this model:")
63
+ print(f" python infer.py --prompt 'your prompt' --model '{repo_id}'")
64
+ print("="*60)
65
+
66
+ except Exception as e:
67
+ print(f"\n❌ Error: {e}")
68
+ import traceback
69
+ traceback.print_exc()
70
+ sys.exit(1)
71
 
 
 
 
 
 
 
 
72
 
73
+ if __name__ == "__main__":
74
+ main()