Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,23 +88,18 @@ QUALITY_PROMPT = ", high quality, detailed, vibrant, professional lighting"
|
|
| 88 |
def infer(
|
| 89 |
images,
|
| 90 |
prompt,
|
| 91 |
-
seed=42,
|
| 92 |
-
randomize_seed=False,
|
| 93 |
-
true_guidance_scale=1.0,
|
| 94 |
-
num_inference_steps=4,
|
| 95 |
-
height=None,
|
| 96 |
-
width=None,
|
| 97 |
-
rewrite_prompt=False,
|
| 98 |
-
num_images_per_prompt=1,
|
| 99 |
progress=gr.Progress(track_tqdm=True),
|
| 100 |
):
|
| 101 |
"""
|
| 102 |
Generates an image using the local Qwen-Image diffusers pipeline.
|
| 103 |
"""
|
| 104 |
negative_prompt = "" # Empty as in original
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# Translate prompt from Albanian to English
|
| 110 |
prompt_final = translate_albanian_to_english(prompt.strip()) + QUALITY_PROMPT
|
|
@@ -145,7 +140,7 @@ def infer(
|
|
| 145 |
num_images_per_prompt=num_images_per_prompt,
|
| 146 |
).images
|
| 147 |
|
| 148 |
-
return image
|
| 149 |
|
| 150 |
# --- Gradio User Interface ---
|
| 151 |
def create_demo():
|
|
@@ -212,7 +207,7 @@ def create_demo():
|
|
| 212 |
border: 1px solid #FFFFFF;
|
| 213 |
border-radius: 4px;
|
| 214 |
}
|
| 215 |
-
input, textarea
|
| 216 |
background: #000000;
|
| 217 |
color: #FFFFFF;
|
| 218 |
border: 1px solid #FFFFFF;
|
|
@@ -221,7 +216,7 @@ def create_demo():
|
|
| 221 |
width: 100%;
|
| 222 |
box-sizing: border-box;
|
| 223 |
}
|
| 224 |
-
input:hover, textarea:hover
|
| 225 |
box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
|
| 226 |
transition: box-shadow 0.3s;
|
| 227 |
}
|
|
@@ -268,12 +263,6 @@ def create_demo():
|
|
| 268 |
footer, .gr-button-secondary {
|
| 269 |
display: none;
|
| 270 |
}
|
| 271 |
-
.gr-accordion {
|
| 272 |
-
background: rgba(0, 0, 0, 0.5);
|
| 273 |
-
border: 1px solid #FFFFFF;
|
| 274 |
-
border-radius: 4px;
|
| 275 |
-
width: 100%;
|
| 276 |
-
}
|
| 277 |
@media (max-width: 768px) {
|
| 278 |
h1 {
|
| 279 |
font-size: 4rem;
|
|
@@ -317,73 +306,12 @@ def create_demo():
|
|
| 317 |
variant="primary",
|
| 318 |
elem_classes="gradio-component"
|
| 319 |
)
|
| 320 |
-
with gr.Accordion("Advanced Settings", open=False):
|
| 321 |
-
seed = gr.Slider(
|
| 322 |
-
label="Seed",
|
| 323 |
-
minimum=0,
|
| 324 |
-
maximum=MAX_SEED,
|
| 325 |
-
step=1,
|
| 326 |
-
value=0,
|
| 327 |
-
elem_classes="gradio-component"
|
| 328 |
-
)
|
| 329 |
-
randomize_seed = gr.Checkbox(
|
| 330 |
-
label="Randomize seed",
|
| 331 |
-
value=True,
|
| 332 |
-
elem_classes="gradio-component"
|
| 333 |
-
)
|
| 334 |
-
true_guidance_scale = gr.Slider(
|
| 335 |
-
label="True guidance scale",
|
| 336 |
-
minimum=1.0,
|
| 337 |
-
maximum=10.0,
|
| 338 |
-
step=0.1,
|
| 339 |
-
value=1.0,
|
| 340 |
-
elem_classes="gradio-component"
|
| 341 |
-
)
|
| 342 |
-
num_inference_steps = gr.Slider(
|
| 343 |
-
label="Number of inference steps",
|
| 344 |
-
minimum=1,
|
| 345 |
-
maximum=40,
|
| 346 |
-
step=1,
|
| 347 |
-
value=4,
|
| 348 |
-
elem_classes="gradio-component"
|
| 349 |
-
)
|
| 350 |
-
height = gr.Slider(
|
| 351 |
-
label="Height",
|
| 352 |
-
minimum=256,
|
| 353 |
-
maximum=2048,
|
| 354 |
-
step=8,
|
| 355 |
-
value=None,
|
| 356 |
-
elem_classes="gradio-component"
|
| 357 |
-
)
|
| 358 |
-
width = gr.Slider(
|
| 359 |
-
label="Width",
|
| 360 |
-
minimum=256,
|
| 361 |
-
maximum=2048,
|
| 362 |
-
step=8,
|
| 363 |
-
value=None,
|
| 364 |
-
elem_classes="gradio-component"
|
| 365 |
-
)
|
| 366 |
-
rewrite_prompt = gr.Checkbox(
|
| 367 |
-
label="Rewrite prompt (being fixed)",
|
| 368 |
-
value=False,
|
| 369 |
-
elem_classes="gradio-component"
|
| 370 |
-
)
|
| 371 |
|
| 372 |
gr.on(
|
| 373 |
triggers=[run_button.click, prompt.submit],
|
| 374 |
fn=infer,
|
| 375 |
-
inputs=[
|
| 376 |
-
|
| 377 |
-
prompt,
|
| 378 |
-
seed,
|
| 379 |
-
randomize_seed,
|
| 380 |
-
true_guidance_scale,
|
| 381 |
-
num_inference_steps,
|
| 382 |
-
height,
|
| 383 |
-
width,
|
| 384 |
-
rewrite_prompt,
|
| 385 |
-
],
|
| 386 |
-
outputs=[result, seed],
|
| 387 |
)
|
| 388 |
|
| 389 |
return demo
|
|
|
|
| 88 |
def infer(
|
| 89 |
images,
|
| 90 |
prompt,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
progress=gr.Progress(track_tqdm=True),
|
| 92 |
):
|
| 93 |
"""
|
| 94 |
Generates an image using the local Qwen-Image diffusers pipeline.
|
| 95 |
"""
|
| 96 |
negative_prompt = "" # Empty as in original
|
| 97 |
+
seed = random.randint(0, MAX_SEED) # Default: randomize_seed=True
|
| 98 |
+
true_guidance_scale = 1.0 # Default
|
| 99 |
+
num_inference_steps = 4 # Default
|
| 100 |
+
height = None # Default
|
| 101 |
+
width = None # Default
|
| 102 |
+
num_images_per_prompt = 1 # Default
|
| 103 |
|
| 104 |
# Translate prompt from Albanian to English
|
| 105 |
prompt_final = translate_albanian_to_english(prompt.strip()) + QUALITY_PROMPT
|
|
|
|
| 140 |
num_images_per_prompt=num_images_per_prompt,
|
| 141 |
).images
|
| 142 |
|
| 143 |
+
return image
|
| 144 |
|
| 145 |
# --- Gradio User Interface ---
|
| 146 |
def create_demo():
|
|
|
|
| 207 |
border: 1px solid #FFFFFF;
|
| 208 |
border-radius: 4px;
|
| 209 |
}
|
| 210 |
+
input, textarea {
|
| 211 |
background: #000000;
|
| 212 |
color: #FFFFFF;
|
| 213 |
border: 1px solid #FFFFFF;
|
|
|
|
| 216 |
width: 100%;
|
| 217 |
box-sizing: border-box;
|
| 218 |
}
|
| 219 |
+
input:hover, textarea:hover {
|
| 220 |
box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
|
| 221 |
transition: box-shadow 0.3s;
|
| 222 |
}
|
|
|
|
| 263 |
footer, .gr-button-secondary {
|
| 264 |
display: none;
|
| 265 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
@media (max-width: 768px) {
|
| 267 |
h1 {
|
| 268 |
font-size: 4rem;
|
|
|
|
| 306 |
variant="primary",
|
| 307 |
elem_classes="gradio-component"
|
| 308 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
gr.on(
|
| 311 |
triggers=[run_button.click, prompt.submit],
|
| 312 |
fn=infer,
|
| 313 |
+
inputs=[input_images, prompt],
|
| 314 |
+
outputs=[result],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
)
|
| 316 |
|
| 317 |
return demo
|