Enzo8930302 commited on
Commit
35a7998
Β·
verified Β·
1 Parent(s): eb82bf6

Upload QUICK_REFERENCE.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. QUICK_REFERENCE.md +250 -0
QUICK_REFERENCE.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Quick Reference - Hugging Face Integration
2
+
3
+ ## Upload Model to HF Hub
4
+
5
+ ### Option 1: Interactive (Easiest)
6
+ ```bash
7
+ python publish_to_hf.py
8
+ # Enter token when prompted
9
+ # Enter repo_id when prompted (e.g., Enzo8930302/ByteDream)
10
+ ```
11
+
12
+ ### Option 2: Command Line
13
+ ```bash
14
+ python publish_to_hf.py hf_xxxxxxxxxxxxx Enzo8930302/ByteDream
15
+ ```
16
+
17
+ ### Option 3: Python Code
18
+ ```python
19
+ from bytedream import ByteDreamGenerator
20
+
21
+ generator = ByteDreamGenerator(model_path="./models/bytedream")
22
+ generator.push_to_hub(
23
+ repo_id="Enzo8930302/ByteDream",
24
+ token="hf_xxxxx"
25
+ )
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Load Model from HF Hub
31
+
32
+ ### Python - Generator
33
+ ```python
34
+ from bytedream import ByteDreamGenerator
35
+
36
+ generator = ByteDreamGenerator(hf_repo_id="Enzo8930302/ByteDream")
37
+ image = generator.generate("Your prompt")
38
+ image.save("output.png")
39
+ ```
40
+
41
+ ### Python - Pipeline
42
+ ```python
43
+ from bytedream.pipeline import ByteDreamPipeline
44
+
45
+ pipeline = ByteDreamPipeline.from_pretrained("Enzo8930302/ByteDream")
46
+ result = pipeline("Your prompt")
47
+ result[0].save("output.png")
48
+ ```
49
+
50
+ ### Command Line
51
+ ```bash
52
+ python infer.py --prompt "Dragon flying" --hf_repo "Enzo8930302/ByteDream" --output dragon.png
53
+ ```
54
+
55
+ ### Web Interface
56
+ ```bash
57
+ # Set environment variable
58
+ export HF_REPO_ID=Enzo8930302/ByteDream
59
+
60
+ # Run app
61
+ python app.py
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Deploy to Hugging Face Spaces
67
+
68
+ 1. **Create Space**: https://huggingface.co/spaces β†’ Create new Space
69
+ 2. **Choose**: Gradio SDK + CPU Basic
70
+ 3. **Push files**:
71
+ ```bash
72
+ git clone https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME
73
+ cp -r ../Byte\ Dream/* SPACE_NAME/
74
+ cd SPACE_NAME
75
+ git add .
76
+ git commit -m "Deploy Byte Dream"
77
+ git push
78
+ ```
79
+ 4. **Set env var**: In Space settings β†’ Add `HF_REPO_ID=Enzo8930302/ByteDream`
80
+ 5. **Done!** Available at: `https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME`
81
+
82
+ ---
83
+
84
+ ## Common Commands
85
+
86
+ ### Get HF Token
87
+ - Go to: https://huggingface.co/settings/tokens
88
+ - Click "New token"
89
+ - Copy token (starts with `hf_`)
90
+
91
+ ### Check Model Exists
92
+ ```bash
93
+ # List files in your HF repo
94
+ huggingface-cli ls Enzo8930302/ByteDream
95
+ ```
96
+
97
+ ### Download Model Manually
98
+ ```python
99
+ from huggingface_hub import snapshot_download
100
+
101
+ snapshot_download(repo_id="Enzo8930302/ByteDream")
102
+ ```
103
+
104
+ ### Test Installation
105
+ ```bash
106
+ python -c "from huggingface_hub import login; print('OK')"
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Environment Variables
112
+
113
+ ```bash
114
+ # Load model from HF in app.py
115
+ export HF_REPO_ID=Enzo8930302/ByteDream
116
+
117
+ # Custom model path
118
+ export MODEL_PATH=./models/bytedream
119
+
120
+ # Set HF cache directory
121
+ export HF_HOME=~/.cache/huggingface
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Example Prompts
127
+
128
+ ```python
129
+ prompts = [
130
+ "A beautiful sunset over mountains, digital art",
131
+ "Cyberpunk city at night, neon lights, futuristic",
132
+ "Fantasy dragon breathing fire, dramatic lighting",
133
+ "Peaceful cottage in meadow, flowers, sunny day",
134
+ "Underwater coral reef, tropical fish, sunlight",
135
+ "Abstract geometric art, colorful shapes, modern",
136
+ ]
137
+
138
+ from bytedream import ByteDreamGenerator
139
+ generator = ByteDreamGenerator(hf_repo_id="Enzo8930302/ByteDream")
140
+
141
+ for i, prompt in enumerate(prompts):
142
+ image = generator.generate(prompt, num_inference_steps=50)
143
+ image.save(f"image_{i}.png")
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Troubleshooting Quick Fixes
149
+
150
+ **Error: Repository not found**
151
+ ```python
152
+ # Make repo public or provide token
153
+ from huggingface_hub import login
154
+ login(token="hf_xxxxx")
155
+ ```
156
+
157
+ **Error: Out of memory**
158
+ ```python
159
+ # Reduce size
160
+ generator.generate(width=256, height=256)
161
+ # Fewer steps
162
+ generator.generate(num_inference_steps=20)
163
+ ```
164
+
165
+ **Error: Model not trained**
166
+ ```bash
167
+ # Train first
168
+ python train.py
169
+ # Or download from HF
170
+ python infer.py --hf_repo username/model --prompt "test"
171
+ ```
172
+
173
+ ---
174
+
175
+ ## File Structure on HF
176
+
177
+ ```
178
+ username/ByteDream/
179
+ β”œβ”€β”€ unet/
180
+ β”‚ └── pytorch_model.bin
181
+ β”œβ”€β”€ vae/
182
+ β”‚ └── pytorch_model.bin
183
+ β”œβ”€β”€ scheduler/
184
+ β”‚ └── scheduler_config.json
185
+ β”œβ”€β”€ model_index.json
186
+ β”œβ”€β”€ config.yaml
187
+ └── README.md
188
+ ```
189
+
190
+ ---
191
+
192
+ ## API Methods Summary
193
+
194
+ ### ByteDreamGenerator
195
+ ```python
196
+ # Initialize with HF model
197
+ ByteDreamGenerator(hf_repo_id="username/repo")
198
+
199
+ # Upload to HF
200
+ generator.push_to_hub(repo_id="username/repo", token="hf_xxx")
201
+
202
+ # Save locally
203
+ generator.save_pretrained("./models/bytedream")
204
+ ```
205
+
206
+ ### ByteDreamPipeline
207
+ ```python
208
+ # Load from HF
209
+ pipeline = ByteDreamPipeline.from_pretrained("username/repo")
210
+
211
+ # Load from local
212
+ pipeline = ByteDreamPipeline.from_pretrained("./models/bytedream")
213
+
214
+ # Save to HF
215
+ pipeline.save_pretrained("./models/bytedream")
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Complete Workflow Example
221
+
222
+ ```python
223
+ # 1. Train (if needed)
224
+ # python train.py
225
+
226
+ # 2. Load model
227
+ from bytedream import ByteDreamGenerator
228
+ generator = ByteDreamGenerator(model_path="./models/bytedream")
229
+
230
+ # 3. Test generation
231
+ image = generator.generate("Test prompt")
232
+ image.save("test.png")
233
+
234
+ # 4. Upload to HF
235
+ generator.push_to_hub(
236
+ repo_id="Enzo8930302/ByteDream",
237
+ token="hf_xxxxxxxx"
238
+ )
239
+
240
+ print("βœ“ Uploaded to HF!")
241
+
242
+ # 5. Use from HF (new session)
243
+ generator2 = ByteDreamGenerator(hf_repo_id="Enzo8930302/ByteDream")
244
+ image2 = generator2.generate("Amazing prompt")
245
+ image2.save("amazing.png")
246
+ ```
247
+
248
+ ---
249
+
250
+ **More Info**: See `HF_INTEGRATION_GUIDE.md` for detailed documentation