Spaces:
Running
on
Zero
Running
on
Zero
Update app_local.py
Browse files- app_local.py +13 -12
app_local.py
CHANGED
|
@@ -325,7 +325,7 @@ def infer(
|
|
| 325 |
seed=42,
|
| 326 |
randomize_seed=False,
|
| 327 |
true_guidance_scale=4.0,
|
| 328 |
-
num_inference_steps=
|
| 329 |
rewrite_prompt=True,
|
| 330 |
num_images_per_prompt=1,
|
| 331 |
preset_type=None,
|
|
@@ -391,7 +391,7 @@ def infer(
|
|
| 391 |
batch_prompts = [f"{original_prompt}, {preset_prompt}" for preset_prompt in non_empty_preset_prompts]
|
| 392 |
num_images_per_prompt = len(non_empty_preset_prompts) # Use actual count of non-empty prompts
|
| 393 |
prompt_info = (
|
| 394 |
-
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #2196F3
|
| 395 |
f"<h4 style='margin-top: 0;'>🎨 Preset: {preset_type}</h4>"
|
| 396 |
f"<p>{preset['description']}</p>"
|
| 397 |
f"<p><strong>Base Prompt:</strong> {original_prompt}</p>"
|
|
@@ -403,7 +403,7 @@ def infer(
|
|
| 403 |
# Fallback to manual if no valid prompts
|
| 404 |
batch_prompts = [prompt]
|
| 405 |
prompt_info = (
|
| 406 |
-
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #FF9800
|
| 407 |
f"<h4 style='margin-top: 0;'>⚠️ Invalid Preset</h4>"
|
| 408 |
f"<p>No valid prompts found. Using manual prompt.</p>"
|
| 409 |
f"<p><strong>Prompt:</strong> {original_prompt}</p>"
|
|
@@ -418,7 +418,7 @@ def infer(
|
|
| 418 |
enhanced_instruction = polish_prompt(original_prompt)
|
| 419 |
if enhanced_instruction and enhanced_instruction != original_prompt:
|
| 420 |
prompt_info = (
|
| 421 |
-
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #4CAF50
|
| 422 |
f"<h4 style='margin-top: 0;'>🚀 Prompt Enhancement</h4>"
|
| 423 |
f"<p><strong>Original:</strong> {original_prompt}</p>"
|
| 424 |
f"<p><strong style='color:#2E7D32;'>Enhanced:</strong> {enhanced_instruction}</p>"
|
|
@@ -427,23 +427,23 @@ def infer(
|
|
| 427 |
batch_prompts = [enhanced_instruction]
|
| 428 |
else:
|
| 429 |
prompt_info = (
|
| 430 |
-
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #FF9800
|
| 431 |
f"<h4 style='margin-top: 0;'>📝 Prompt Enhancement</h4>"
|
| 432 |
f"<p>No enhancement applied or enhancement failed</p>"
|
| 433 |
f"</div>"
|
| 434 |
)
|
| 435 |
except Exception as e:
|
| 436 |
-
|
| 437 |
gr.Warning(f"Prompt enhancement failed: {str(e)}")
|
| 438 |
prompt_info = (
|
| 439 |
-
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #FF5252
|
| 440 |
f"<h4 style='margin-top: 0;'>⚠️ Enhancement Not Applied</h4>"
|
| 441 |
f"<p>Using original prompt. Error: {str(e)[:100]}</p>"
|
| 442 |
f"</div>"
|
| 443 |
)
|
| 444 |
else:
|
| 445 |
prompt_info = (
|
| 446 |
-
f"<div style='margin:10px; padding:10px; border-radius:8px
|
| 447 |
f"<h4 style='margin-top: 0;'>📝 Original Prompt</h4>"
|
| 448 |
f"<p>{original_prompt}</p>"
|
| 449 |
f"</div>"
|
|
@@ -489,7 +489,7 @@ def infer(
|
|
| 489 |
gc.collect()
|
| 490 |
gr.Error(f"Image generation failed: {str(e)}")
|
| 491 |
return [], base_seed, (
|
| 492 |
-
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #dd2c00
|
| 493 |
f"<h4 style='margin-top: 0;'>⚠️ Processing Error</h4>"
|
| 494 |
f"<p>{str(e)[:200]}</p>"
|
| 495 |
f"</div>"
|
|
@@ -607,9 +607,10 @@ with gr.Blocks(title="'Qwen Image Edit' Model Playground & Showcase [4-Step Ligh
|
|
| 607 |
result = gr.Gallery(
|
| 608 |
label="Edited Images",
|
| 609 |
columns=lambda x: min(x, 2),
|
| 610 |
-
height=
|
| 611 |
-
object_fit="
|
| 612 |
-
preview=True
|
|
|
|
| 613 |
)
|
| 614 |
prompt_info = gr.HTML(
|
| 615 |
value="<div style='padding:15px; margin-top:15px'>"
|
|
|
|
| 325 |
seed=42,
|
| 326 |
randomize_seed=False,
|
| 327 |
true_guidance_scale=4.0,
|
| 328 |
+
num_inference_steps=3,
|
| 329 |
rewrite_prompt=True,
|
| 330 |
num_images_per_prompt=1,
|
| 331 |
preset_type=None,
|
|
|
|
| 391 |
batch_prompts = [f"{original_prompt}, {preset_prompt}" for preset_prompt in non_empty_preset_prompts]
|
| 392 |
num_images_per_prompt = len(non_empty_preset_prompts) # Use actual count of non-empty prompts
|
| 393 |
prompt_info = (
|
| 394 |
+
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #2196F3;>"
|
| 395 |
f"<h4 style='margin-top: 0;'>🎨 Preset: {preset_type}</h4>"
|
| 396 |
f"<p>{preset['description']}</p>"
|
| 397 |
f"<p><strong>Base Prompt:</strong> {original_prompt}</p>"
|
|
|
|
| 403 |
# Fallback to manual if no valid prompts
|
| 404 |
batch_prompts = [prompt]
|
| 405 |
prompt_info = (
|
| 406 |
+
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #FF9800;>"
|
| 407 |
f"<h4 style='margin-top: 0;'>⚠️ Invalid Preset</h4>"
|
| 408 |
f"<p>No valid prompts found. Using manual prompt.</p>"
|
| 409 |
f"<p><strong>Prompt:</strong> {original_prompt}</p>"
|
|
|
|
| 418 |
enhanced_instruction = polish_prompt(original_prompt)
|
| 419 |
if enhanced_instruction and enhanced_instruction != original_prompt:
|
| 420 |
prompt_info = (
|
| 421 |
+
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #4CAF50;>"
|
| 422 |
f"<h4 style='margin-top: 0;'>🚀 Prompt Enhancement</h4>"
|
| 423 |
f"<p><strong>Original:</strong> {original_prompt}</p>"
|
| 424 |
f"<p><strong style='color:#2E7D32;'>Enhanced:</strong> {enhanced_instruction}</p>"
|
|
|
|
| 427 |
batch_prompts = [enhanced_instruction]
|
| 428 |
else:
|
| 429 |
prompt_info = (
|
| 430 |
+
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #FF9800;>"
|
| 431 |
f"<h4 style='margin-top: 0;'>📝 Prompt Enhancement</h4>"
|
| 432 |
f"<p>No enhancement applied or enhancement failed</p>"
|
| 433 |
f"</div>"
|
| 434 |
)
|
| 435 |
except Exception as e:
|
| 436 |
+
logger.warning(f"Prompt enhancement error: {str(e)}") # Debug logging
|
| 437 |
gr.Warning(f"Prompt enhancement failed: {str(e)}")
|
| 438 |
prompt_info = (
|
| 439 |
+
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #FF5252;>"
|
| 440 |
f"<h4 style='margin-top: 0;'>⚠️ Enhancement Not Applied</h4>"
|
| 441 |
f"<p>Using original prompt. Error: {str(e)[:100]}</p>"
|
| 442 |
f"</div>"
|
| 443 |
)
|
| 444 |
else:
|
| 445 |
prompt_info = (
|
| 446 |
+
f"<div style='margin:10px; padding:10px; border-radius:8px;>"
|
| 447 |
f"<h4 style='margin-top: 0;'>📝 Original Prompt</h4>"
|
| 448 |
f"<p>{original_prompt}</p>"
|
| 449 |
f"</div>"
|
|
|
|
| 489 |
gc.collect()
|
| 490 |
gr.Error(f"Image generation failed: {str(e)}")
|
| 491 |
return [], base_seed, (
|
| 492 |
+
f"<div style='margin:10px; padding:15px; border-radius:8px; border-left:4px solid #dd2c00;>"
|
| 493 |
f"<h4 style='margin-top: 0;'>⚠️ Processing Error</h4>"
|
| 494 |
f"<p>{str(e)[:200]}</p>"
|
| 495 |
f"</div>"
|
|
|
|
| 607 |
result = gr.Gallery(
|
| 608 |
label="Edited Images",
|
| 609 |
columns=lambda x: min(x, 2),
|
| 610 |
+
height="80vh",
|
| 611 |
+
object_fit="contain",
|
| 612 |
+
preview=True,
|
| 613 |
+
container=True
|
| 614 |
)
|
| 615 |
prompt_info = gr.HTML(
|
| 616 |
value="<div style='padding:15px; margin-top:15px'>"
|