aexyb commited on
Commit
3a89794
Β·
verified Β·
1 Parent(s): 018ef76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +259 -136
app.py CHANGED
@@ -1,115 +1,124 @@
1
- """
2
- FLUX.2-klein-4B Q8_0 Generator
3
- Lightweight version - NO ComfyUI needed!
4
- Uses: diffusers + gguf direct loading
5
- """
6
-
7
  import os
8
  import sys
9
- import urllib.request
10
  from pathlib import Path
11
  from datetime import datetime
12
 
13
- # Paths
 
 
 
14
  BASE = Path.cwd()
15
  MODELS = BASE / "models"
16
  OUTPUTS = BASE / "outputs"
17
 
18
- MODEL_FILE = "flux.2-klein-4b-Q8_0.gguf"
19
- MODEL_URL = f"https://huggingface.co/unsloth/FLUX.2-klein-4B-GGUF/resolve/main/{MODEL_FILE}"
 
20
 
21
- def log(msg):
22
- print(f"[{datetime.now().strftime('%H:%M:%S')}] {msg}")
23
-
24
- def setup():
25
- """Download model only - no heavy installs!"""
26
- try:
27
- log(f"Creating directories...")
28
- MODELS.mkdir(exist_ok=True)
29
- OUTPUTS.mkdir(exist_ok=True)
30
-
31
- model_path = MODELS / MODEL_FILE
32
-
33
- if not model_path.exists():
34
- log(f"⬇️ Downloading {MODEL_FILE} from HuggingFace...")
35
- log(f" URL: {MODEL_URL}")
36
-
37
- # Download with progress
38
- def progress(count, block_size, total_size):
39
- percent = count * block_size * 100 // total_size if total_size > 0 else 0
40
- mb = count * block_size / (1024*1024)
41
- total_mb = total_size / (1024*1024)
42
- print(f"\r ⏳ {percent}% ({mb:.1f}/{total_mb:.1f} MB)", end="", flush=True)
43
-
44
- urllib.request.urlretrieve(MODEL_URL, model_path, progress)
45
-
46
- size_mb = model_path.stat().st_size / (1024*1024)
47
- print(f"\n βœ… Downloaded ({size_mb:.1f} MB)")
48
- else:
49
- size_mb = model_path.stat().st_size / (1024*1024)
50
- log(f"βœ… Model exists ({size_mb:.1f} MB)")
51
 
52
- log("βœ… Setup complete!")
 
53
  return True
54
-
55
- except Exception as e:
56
- log(f"❌ Error: {e}")
57
  return False
58
 
59
 
60
- def generate_image(prompt, neg_prompt="", width=1024, height=1024, steps=20, cfg=7.0, seed=-1, progress=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  """
62
- Generate image using GGUF model with diffusers
63
  """
64
 
65
- if not prompt.strip():
66
- return None, "❌ Please enter a prompt!"
 
67
 
68
- model_path = MODELS / MODEL_FILE
69
 
70
- if not model_path.exists():
71
- return None, f"""❌ Model not found!
 
72
 
73
- Expected: {model_path}
74
 
75
- Please wait for setup to complete, or manually upload the model file."""
 
 
 
76
 
77
  try:
 
78
  import torch
79
  from diffusers import FluxPipeline
80
- from transformers import T5EncoderModel, CLIPTokenizer
81
 
82
  if progress:
83
- progress(0.1, desc="Loading model (first time takes ~2 min)...")
84
 
85
- log("🎨 Loading FLUX GGUF model...")
86
- log(f" Model: {model_path}")
87
- log(f" Prompt: {prompt[:50]}...")
88
 
89
- # Load pipeline with GGUF quantization
90
  pipe = FluxPipeline.from_single_file(
91
- str(model_path),
92
- torch_dtype=torch.bfloat16,
93
- use_safetensors=True,
94
  )
95
 
96
- # CPU offloading for low memory
97
  pipe.enable_model_cpu_offload()
98
 
99
  if progress:
100
- progress(0.3, desc="Generating image...")
101
 
102
- log(f"πŸ–ΌοΈ Generating ({width}x{height}, {steps} steps)...")
103
 
104
  # Set seed
105
  generator = None
106
  if seed > 0:
107
  generator = torch.Generator(device="cpu").manual_seed(seed)
 
 
 
 
 
108
 
109
- # Generate
110
  result = pipe(
111
  prompt=prompt,
112
- negative_prompt=neg_prompt or None,
113
  height=int(height),
114
  width=int(width),
115
  num_inference_steps=int(steps),
@@ -118,47 +127,45 @@ Please wait for setup to complete, or manually upload the model file."""
118
  )
119
 
120
  if progress:
121
- progress(0.9, desc="Saving image...")
122
 
123
- # Save output
 
124
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
125
- output_filename = f"output_{timestamp}.png"
126
  output_path = str(OUTPUTS_DIR / output_filename)
127
 
128
- OUTPUTS_DIR.mkdir(exist_ok=True)
129
  result.images[0].save(output_path)
130
 
131
  file_size = Path(output_path).stat().st_size / (1024*1024)
132
 
133
  if progress:
134
- progress(1.0, desc="Done!")
135
 
136
- status = f"""βœ… Image generated!
137
 
138
  πŸ“Š Details:
139
- β€’ File: {output_filename}
140
- β€’ Size: {file_size:.2f} MB
141
- β€’ Resolution: {width}Γ—{height}
142
- β€’ Steps: {steps}
143
- β€’ CFG: {cfg}
144
- β€’ Seed: {seed if seed > 0 else 'random'}
145
 
146
- πŸ’‘ Generated with FLUX.2-klein-4B Q8_0"""
 
147
 
148
  log(f"βœ… Saved: {output_path} ({file_size:.1f} MB)")
149
 
150
  return output_path, status
151
 
152
  except ImportError as e:
153
- missing = str(e).split("'")[1] if "'" in str(e) else str(e)
154
- return None, f"""❌ Missing library: {missing}
155
-
156
- Installing now... (this may take 1-2 minutes)
157
 
158
- Run in terminal:
159
- pip install diffusers transformers accelerate safetensors sentencepiece
160
 
161
- Or add to requirements.txt:
162
  diffusers>=0.30.0
163
  transformers>=4.44.0
164
  accelerate>=0.33.0
@@ -167,56 +174,90 @@ sentencepiece>=0.2.0"""
167
 
168
  except Exception as e:
169
  error_type = type(e).__name__
170
- error_msg = str(e)[:500]
171
 
172
- log(f"❌ Generation failed: {error_type}: {error_msg}")
173
 
174
- return None, f"""❌ Generation failed!
 
 
 
175
 
176
- Error Type: {error_type}
177
- Message: {error_msg}
 
 
 
 
 
 
178
 
179
- Common fixes:
180
- β€’ Reduce resolution (try 512Γ—512)
181
- β€’ Reduce steps (try 10-15)
182
- β€’ Check available RAM (need ~12GB+ free)
 
 
 
183
 
184
- Full error logged above."""
 
 
 
185
 
186
 
187
  # ══════════════════════════════════════════════
188
- # RUN SETUP
189
  # ══════════════════════════════════════════════
190
 
191
  print("\n" + "="*60)
192
- print("🎨 FLUX.2-klein-4B Q8_0 GENERATOR")
193
  print("="*60 + "\n")
194
 
195
- setup_success = setup()
 
196
 
197
- if setup_success:
198
- print("\nβœ… Ready to generate images!\n")
199
- else:
200
- print("\n⚠️ Setup had issues - check logs above\n")
 
 
 
 
 
 
 
 
201
 
202
  # ══════════════════════════════════════════════
203
- # GRADIO INTERFACE
204
  # ══════════════════════════════════════════════
205
 
206
  import gradio as gr
207
 
208
- with gr.Blocks(
209
- title="FLUX.2-klein-4B Q8_0",
210
- theme=gr.themes.Soft()
211
- ) as demo:
212
 
213
  gr.Markdown("""
214
- # 🎨 FLUX.2-klein-4B (Q8_0) Generator
215
 
216
- ### Model: `unsloth/FLUX.2-klein-4B-GGUF`
217
- ### Backend: Diffusers (CPU Optimized)
 
218
  """)
219
 
 
 
 
 
 
 
 
 
 
 
 
220
  with gr.Row():
221
  with gr.Column(scale=2):
222
  prompt_input = gr.Textbox(
@@ -228,38 +269,94 @@ with gr.Blocks(
228
 
229
  neg_input = gr.Textbox(
230
  label="🚫 Negative Prompt (optional)",
231
- placeholder="blurry, low quality, deformed...",
232
  lines=2,
233
  value=""
234
  )
235
 
236
  with gr.Column(scale=1):
237
- width_slider = gr.Slider(256, 1024, 1024, step=64, label="↔️ Width")
238
- height_slider = gr.Slider(256, 1024, 1024, step=64, label="↕️ Height")
239
- steps_slider = gr.Slider(1, 50, 20, step=1, label="πŸ”„ Steps")
240
- cfg_slider = gr.Slider(1.0, 20.0, 7.0, step=0.5, label="βš™οΈ CFG Scale")
241
- seed_input = gr.Number(-1, label="🎲 Seed (-1=random)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
  with gr.Row():
244
- gen_btn = gr.Button("πŸš€ Generate Image", variant="primary", size="lg")
245
- clear_btn = gr.Button("πŸ—‘οΈ Clear", size="lg")
 
 
 
 
 
 
 
246
 
247
  with gr.Row():
248
  with gr.Column():
249
- output_image = gr.Image(label="πŸ–ΌοΈ Output", height=450, type="filepath")
 
 
 
 
250
 
251
  with gr.Column():
252
  status_output = gr.Textbox(
253
- label="πŸ“Š Status & Info",
254
- lines=12,
255
- max_lines=20,
256
  interactive=False
257
  )
258
 
 
259
  gen_btn.click(
260
  fn=generate_image,
261
- inputs=[prompt_input, neg_input, width_slider, height_slider,
262
- steps_slider, cfg_slider, seed_input],
 
 
 
 
 
 
 
263
  outputs=[output_image, status_output],
264
  show_progress=True
265
  )
@@ -269,30 +366,56 @@ with gr.Blocks(
269
  "a red fox in snow, detailed, 8k", # Reset prompt
270
  "", # Clear negative
271
  1024, # Default width
272
- 1024, # Default height
273
  20, # Default steps
274
  7.0, # Default CFG
275
  -1, # Random seed
276
  None, # Clear image
277
  "" # Clear status
278
  ),
279
- outputs=[prompt_input, neg_input, width_slider, height_slider,
280
- steps_slider, cfg_slider, seed_input, output_image, status_output]
 
 
 
 
 
 
 
 
 
281
  )
282
 
 
283
  gr.Markdown("""
284
  ---
285
- ### πŸ’‘ Tips for CPU Generation
286
- - **Faster**: Lower resolution (512Γ—512) + fewer steps (10-15)
287
- - **Better Quality**: Higher CFG (7-12) + more steps (25-30)
288
- - **First Run**: Slow (~3-5 min) while model loads into memory
289
- - **Subsequent Runs**: Faster (~1-3 min each)
 
 
 
 
 
 
 
 
290
  """)
291
 
292
 
293
  # ══════════════════════════════════════════════
294
- # LAUNCH
295
  # ══════════════════════════════════════════════
296
 
297
  if __name__ == "__main__":
298
- demo.launch(server_name="0.0.0.0", port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import sys
 
3
  from pathlib import Path
4
  from datetime import datetime
5
 
6
+ # ══════════════════════════════════════════════
7
+ # CONFIGURATION
8
+ # ══════════════════════════════════════════════
9
+
10
  BASE = Path.cwd()
11
  MODELS = BASE / "models"
12
  OUTPUTS = BASE / "outputs"
13
 
14
+ # Model configuration
15
+ MODEL_FILE = None # Will auto-detect
16
+ MODEL_PATH = None
17
 
18
+ def find_model_file():
19
+ """Find the GGUF model file in ./models/"""
20
+ global MODEL_FILE, MODEL_PATH
21
+
22
+ MODELS.mkdir(exist_ok=True)
23
+
24
+ # Look for any .gguf file
25
+ gguf_files = list(MODELS.glob("*.gguf"))
26
+
27
+ if gguf_files:
28
+ # Pick the largest one (likely the main model)
29
+ gguf_files.sort(key=lambda x: x.stat().st_size, reverse=True)
30
+ MODEL_FILE = gguf_files[0].name
31
+ MODEL_PATH = str(gguf_files[0])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ size_mb = gguf_files[0].stat().st_size / (1024*1024)
34
+ print(f"βœ… Found model: {MODEL_FILE} ({size_mb:.1f} MB)")
35
  return True
36
+ else:
37
+ print("❌ No .gguf model files found in ./models/")
38
+ print(f" Contents of {MODELS}: {list(MODELS.iterdir())}")
39
  return False
40
 
41
 
42
+ def log(msg):
43
+ """Timestamped logging"""
44
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] {msg}")
45
+
46
+
47
+ # ══════════════════════════════════════════════
48
+ # GENERATION FUNCTION
49
+ # ══════════════════════════════════════════════
50
+
51
+ def generate_image(
52
+ prompt: str,
53
+ neg_prompt: str = "",
54
+ width: int = 1024,
55
+ height: int = 1024,
56
+ steps: int = 20,
57
+ cfg: float = 7.0,
58
+ seed: int = -1,
59
+ progress=None
60
+ ):
61
  """
62
+ Generate image using Flux GGUF model
63
  """
64
 
65
+ # Validate inputs
66
+ if not prompt or not prompt.strip():
67
+ return None, "❌ Please enter a text prompt!"
68
 
69
+ prompt = prompt.strip()
70
 
71
+ # Check model exists
72
+ if not MODEL_PATH or not Path(MODEL_PATH).exists():
73
+ return None, f"""❌ Model file not found!
74
 
75
+ Expected location: {MODEL_PATH}
76
 
77
+ SOLUTION:
78
+ 1. Ensure download_models.sh ran successfully during build
79
+ 2. Or manually upload a .gguf file to ./models/
80
+ 3. Restart Space"""
81
 
82
  try:
83
+ # Import ML libraries (lazy load)
84
  import torch
85
  from diffusers import FluxPipeline
 
86
 
87
  if progress:
88
+ progress(0.05, desc="Loading pipeline...")
89
 
90
+ log("🎨 Loading FLUX pipeline...")
91
+ log(f" Model: {MODEL_FILE}")
92
+ log(f" Prompt: {prompt[:80]}...")
93
 
94
+ # Load pipeline
95
  pipe = FluxPipeline.from_single_file(
96
+ MODEL_PATH,
97
+ torch_dtype=torch.bfloat16
 
98
  )
99
 
100
+ # Enable CPU offloading for low memory
101
  pipe.enable_model_cpu_offload()
102
 
103
  if progress:
104
+ progress(0.25, desc="Pipeline loaded, generating...")
105
 
106
+ log(f" Parameters: {width}x{height}, {steps} steps, CFG={cfg}")
107
 
108
  # Set seed
109
  generator = None
110
  if seed > 0:
111
  generator = torch.Generator(device="cpu").manual_seed(seed)
112
+ log(f" Seed: {seed}")
113
+ else:
114
+ import random
115
+ seed = random.randint(0, 2**32)
116
+ log(f" Seed: {seed} (random)")
117
 
118
+ # Generate image
119
  result = pipe(
120
  prompt=prompt,
121
+ negative_prompt=neg_prompt.strip() or None,
122
  height=int(height),
123
  width=int(width),
124
  num_inference_steps=int(steps),
 
127
  )
128
 
129
  if progress:
130
+ progress(0.9, desc="Saving output...")
131
 
132
+ # Save image
133
+ OUTPUTS.mkdir(exist_ok=True)
134
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
135
+ output_filename = f"flux_{timestamp}.png"
136
  output_path = str(OUTPUTS_DIR / output_filename)
137
 
 
138
  result.images[0].save(output_path)
139
 
140
  file_size = Path(output_path).stat().st_size / (1024*1024)
141
 
142
  if progress:
143
+ progress(1.0, desc="Complete!")
144
 
145
+ status = f"""βœ… Image Generated Successfully!
146
 
147
  πŸ“Š Details:
148
+ β”œβ”€ File: {output_filename}
149
+ β”œβ”€ Size: {file_size:.2f} MB
150
+ β”œβ”€ Resolution: {width} Γ— {height}
151
+ β”œβ”€ Steps: {steps}
152
+ β”œβ”€ CFG Scale: {cfg}
153
+ └─ Seed: {seed}
154
 
155
+ πŸ’‘ Model: {MODEL_FILE}
156
+ ⏱️ Generation completed!"""
157
 
158
  log(f"βœ… Saved: {output_path} ({file_size:.1f} MB)")
159
 
160
  return output_path, status
161
 
162
  except ImportError as e:
163
+ missing_pkg = str(e).split("'")[1] if "'" in str(e) else str(e)
164
+ return None, f"""❌ Missing Python Package!
 
 
165
 
166
+ Package: {missing_pkg}
 
167
 
168
+ Fix: Add to requirements.txt and restart:
169
  diffusers>=0.30.0
170
  transformers>=4.44.0
171
  accelerate>=0.33.0
 
174
 
175
  except Exception as e:
176
  error_type = type(e).__name__
177
+ error_msg = str(e)[:800]
178
 
179
+ log(f"❌ ERROR: {error_type}: {error_msg}")
180
 
181
+ # Provide helpful suggestions
182
+ if "out of memory" in error_msg.lower():
183
+ suggestion = """
184
+ πŸ”΄ OUT OF MEMORY!
185
 
186
+ Your 18GB RAM is full. Solutions:
187
+ β€’ Reduce resolution to 512Γ—512
188
+ β€’ Reduce steps to 10-15
189
+ β€’ Close other applications
190
+ β€’ Use smaller model (Q4_K_M instead of Q8_0)"""
191
+ elif "CUDA" in error_msg.upper():
192
+ suggestion = """
193
+ ⚠️ GPU/CUDA Error
194
 
195
+ This Space is CPU-only. The pipeline should use CPU offloading.
196
+ If this persists, try restarting the Space."""
197
+ else:
198
+ suggestion = f"""
199
+ Error Details:
200
+ Type: {error_type}
201
+ Message: {error_msg}
202
 
203
+ Check logs above for full traceback."""
204
+
205
+ return None, f"""❌ Generation Failed!
206
+ {suggestion}"""
207
 
208
 
209
  # ══════════════════════════════════════════════
210
+ # INITIALIZATION
211
  # ══════════════════════════════════════════════
212
 
213
  print("\n" + "="*60)
214
+ print("🎨 FLUX.2-klein-4B Generator")
215
  print("="*60 + "\n")
216
 
217
+ # Find model file (should already exist from build)
218
+ model_found = find_model_file()
219
 
220
+ if not model_found:
221
+ print("""
222
+ ⚠️ WARNING: No model file detected!
223
+
224
+ This means either:
225
+ 1. download_models.sh failed during build
226
+ 2. Models weren't uploaded yet
227
+
228
+ TO FIX:
229
+ Option A: Upload .gguf file to ./models/ via Space UI
230
+ Option B: Rebuild Space after fixing download script
231
+ """)
232
 
233
  # ══════════════════════════════════════════════
234
+ # GRADIO INTERFACE (Gradio 6.0 Compatible!)
235
  # ══════════════════════════════════════════════
236
 
237
  import gradio as gr
238
 
239
+ # Create interface WITHOUT theme in constructor (Gradio 6.0 fix)
240
+ with gr.Blocks(title="FLUX.2-klein-4B Q8_0 Generator") as demo:
 
 
241
 
242
  gr.Markdown("""
243
+ # 🎨 FLUX.2-klein-4B (Q8_0) Text-to-Image
244
 
245
+ ### ⚑ CPU-Powered β€’ Diffusers Backend β€’ No GPU Required
246
+
247
+ ---
248
  """)
249
 
250
+ # Status indicator
251
+ status_text = f"""
252
+ **System Status:** {'βœ… Ready' if model_found else '⚠️ No Model Found'}
253
+
254
+ **Model:** `{MODEL_FILE or 'Not detected'}`
255
+
256
+ **Mode:** CPU Inference (18GB RAM optimized)
257
+ """
258
+
259
+ gr.Markdown(status_text)
260
+
261
  with gr.Row():
262
  with gr.Column(scale=2):
263
  prompt_input = gr.Textbox(
 
269
 
270
  neg_input = gr.Textbox(
271
  label="🚫 Negative Prompt (optional)",
272
+ placeholder="blurry, low quality, deformed, ugly...",
273
  lines=2,
274
  value=""
275
  )
276
 
277
  with gr.Column(scale=1):
278
+ width_slider = gr.Slider(
279
+ minimum=256,
280
+ maximum=1024,
281
+ value=1024,
282
+ step=64,
283
+ label="↔️ Width (px)",
284
+ info="Lower = faster"
285
+ )
286
+
287
+ height_slider = gr.Slider(
288
+ minimum=256,
289
+ maximum=1024,
290
+ value=1024,
291
+ step=64,
292
+ label="↕️ Height (px)",
293
+ info="Lower = faster"
294
+ )
295
+
296
+ steps_slider = gr.Slider(
297
+ minimum=1,
298
+ maximum=50,
299
+ value=20,
300
+ step=1,
301
+ label="πŸ”„ Inference Steps",
302
+ info="20 recommended"
303
+ )
304
+
305
+ cfg_slider = gr.Slider(
306
+ minimum=1.0,
307
+ maximum=20.0,
308
+ value=7.0,
309
+ step=0.5,
310
+ label="βš™οΈ CFG Scale",
311
+ info="7.0 good for Flux"
312
+ )
313
+
314
+ seed_input = gr.Number(
315
+ value=-1,
316
+ label="🎲 Seed",
317
+ info="-1 = random",
318
+ precision=0
319
+ )
320
 
321
  with gr.Row():
322
+ gen_btn = gr.Button(
323
+ "πŸš€ Generate Image",
324
+ variant="primary",
325
+ size="lg"
326
+ )
327
+ clear_btn = gr.Button(
328
+ "πŸ—‘οΈ Clear All",
329
+ size="lg"
330
+ )
331
 
332
  with gr.Row():
333
  with gr.Column():
334
+ output_image = gr.Image(
335
+ label="πŸ–ΌοΈ Generated Output",
336
+ height=500,
337
+ type="filepath"
338
+ )
339
 
340
  with gr.Column():
341
  status_output = gr.Textbox(
342
+ label="πŸ“Š Status & Information",
343
+ lines=14,
344
+ max_lines=25,
345
  interactive=False
346
  )
347
 
348
+ # Event handlers
349
  gen_btn.click(
350
  fn=generate_image,
351
+ inputs=[
352
+ prompt_input,
353
+ neg_input,
354
+ width_slider,
355
+ height_slider,
356
+ steps_slider,
357
+ cfg_slider,
358
+ seed_input
359
+ ],
360
  outputs=[output_image, status_output],
361
  show_progress=True
362
  )
 
366
  "a red fox in snow, detailed, 8k", # Reset prompt
367
  "", # Clear negative
368
  1024, # Default width
369
+ 1024, # Default height
370
  20, # Default steps
371
  7.0, # Default CFG
372
  -1, # Random seed
373
  None, # Clear image
374
  "" # Clear status
375
  ),
376
+ outputs=[
377
+ prompt_input,
378
+ neg_input,
379
+ width_slider,
380
+ height_slider,
381
+ steps_slider,
382
+ cfg_slider,
383
+ seed_input,
384
+ output_image,
385
+ status_output
386
+ ]
387
  )
388
 
389
+ # Footer help text
390
  gr.Markdown("""
391
  ---
392
+ ### πŸ’‘ Performance Tips (CPU Mode)
393
+
394
+ | Setting | Fast (Quick Preview) | Quality (Best Results) |
395
+ |---------|---------------------|----------------------|
396
+ | **Resolution** | 512 Γ— 512 | 1024 Γ— 1024 |
397
+ | **Steps** | 10-15 | 25-30 |
398
+ | **CFG Scale** | 5.0-7.0 | 7.0-12.0 |
399
+
400
+ ⏱️ **First generation**: ~3-5 minutes (model loading)
401
+
402
+ ⏱️ **Subsequent generations**: ~1-3 minutes each
403
+
404
+ πŸ”΄ **Memory**: Keep total under 12GB usage on 18GB system
405
  """)
406
 
407
 
408
  # ══════════════════════════════════════════════
409
+ # LAUNCH (Gradio 6.0 Compatible!)
410
  # ══════════════════════════════════════════════
411
 
412
  if __name__ == "__main__":
413
+ log("πŸš€ Launching web interface...")
414
+
415
+ # FIXED: Move theme to launch() for Gradio 6.0+
416
+ demo.launch(
417
+ server_name="0.0.0.0",
418
+ server_port=7860,
419
+ share=False,
420
+ # theme=gr.themes.Soft() # Uncomment if you want custom theme
421
+ )