Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,6 +27,7 @@ def apply_preset(preset_name):
|
|
| 27 |
preset["lora_scale"],
|
| 28 |
preset["depth_control_scale"],
|
| 29 |
preset["identity_control_scale"],
|
|
|
|
| 30 |
f"[APPLIED] {preset_name}\n{preset['description']}"
|
| 31 |
)
|
| 32 |
|
|
@@ -40,6 +41,7 @@ def process_image(
|
|
| 40 |
guidance_scale,
|
| 41 |
depth_control_scale,
|
| 42 |
identity_control_scale,
|
|
|
|
| 43 |
lora_scale,
|
| 44 |
identity_preservation,
|
| 45 |
strength,
|
|
@@ -62,6 +64,7 @@ def process_image(
|
|
| 62 |
guidance_scale=guidance_scale,
|
| 63 |
depth_control_scale=depth_control_scale,
|
| 64 |
identity_control_scale=identity_control_scale,
|
|
|
|
| 65 |
lora_scale=lora_scale,
|
| 66 |
identity_preservation=identity_preservation,
|
| 67 |
strength=strength,
|
|
@@ -106,7 +109,8 @@ def get_model_status():
|
|
| 106 |
status_text += f"- Custom Checkpoint (Horizon): {'[OK] Loaded' if converter.models_loaded['custom_checkpoint'] else '[OK] Using SDXL base'}\n"
|
| 107 |
status_text += f"- LORA (RetroArt): {'[OK] Loaded' if converter.models_loaded['lora'] else ' Disabled'}\n"
|
| 108 |
status_text += f"- InstantID: {'[OK] Loaded' if converter.models_loaded['instantid'] else ' Disabled'}\n"
|
| 109 |
-
status_text += f"-
|
|
|
|
| 110 |
status_text += f"- IP-Adapter (Face Embeddings): {'[OK] Loaded' if converter.models_loaded.get('ip_adapter', False) else ' Keypoints only'}\n"
|
| 111 |
return status_text
|
| 112 |
return "**Model status unavailable**"
|
|
@@ -174,6 +178,7 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 174 |
**[CONFIG] Advanced Configuration:**
|
| 175 |
- Pipeline: **Img2Img** (structure preservation)
|
| 176 |
- Face System: **CLIP + InsightFace** (dual embeddings)
|
|
|
|
| 177 |
- **[ADVANCED] Enhanced Resampler:** 10 layers, 20 heads (+3-5% quality)
|
| 178 |
- **[ADVANCED] Adaptive Attention:** Context-aware scaling (+2-3% quality)
|
| 179 |
- **[ADVANCED] Multi-Scale Processing:** 3-scale face analysis (+1-2% quality)
|
|
@@ -194,14 +199,14 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 194 |
|
| 195 |
prompt = gr.Textbox(
|
| 196 |
label="Prompt (trigger word auto-added)",
|
| 197 |
-
value="
|
| 198 |
lines=3,
|
| 199 |
info=f"'{TRIGGER_WORD}' will be automatically added"
|
| 200 |
)
|
| 201 |
|
| 202 |
negative_prompt = gr.Textbox(
|
| 203 |
label="Negative Prompt",
|
| 204 |
-
value="
|
| 205 |
lines=2
|
| 206 |
)
|
| 207 |
|
|
@@ -280,6 +285,16 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 280 |
label="InstantID ControlNet Scale (facial keypoints structure)"
|
| 281 |
)
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
identity_preservation = gr.Slider(
|
| 284 |
minimum=0.3,
|
| 285 |
maximum=2.0,
|
|
@@ -329,6 +344,7 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 329 |
### Tips for Maximum Quality Results:
|
| 330 |
|
| 331 |
**[OPTIMIZATIONS] Advanced Optimizations Active:**
|
|
|
|
| 332 |
- **Enhanced Resampler:** 10 layers, 20 heads (+3-5% quality)
|
| 333 |
- **Adaptive Attention:** Context-aware scaling (+2-3% quality)
|
| 334 |
- **Multi-Scale Processing:** 3-scale face analysis (+1-2% quality)
|
|
@@ -351,7 +367,7 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 351 |
**[ADAPTIVE] Automatic Adjustments:**
|
| 352 |
- Small faces (< 50K px): Boosts identity preservation to 1.8
|
| 353 |
- Low confidence (< 80%): Increases identity control to 0.9
|
| 354 |
-
- Profile views (> 20
|
| 355 |
- Good quality faces: Uses your selected parameters
|
| 356 |
|
| 357 |
**[PARAMETERS] Parameter Relationships:**
|
|
@@ -367,7 +383,7 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 367 |
- Validates parameter combinations for predictability
|
| 368 |
- Prevents identity-LORA conflicts
|
| 369 |
- Keeps CFG in optimal LCM range
|
| 370 |
-
- Balances ControlNet scales
|
| 371 |
- Recommended: Always ON
|
| 372 |
|
| 373 |
**[SEED] Reproducibility:**
|
|
@@ -390,55 +406,54 @@ with gr.Blocks(title="Pixagram - AI Pixel Art Generator", theme=gr.themes.Soft()
|
|
| 390 |
- Resolution: Auto-optimized to 896x1152 or 832x1216
|
| 391 |
""")
|
| 392 |
|
| 393 |
-
# Preset button click events
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
preset_btn_1.click(
|
| 395 |
fn=lambda: apply_preset("Ultra Fidelity"),
|
| 396 |
inputs=[],
|
| 397 |
-
outputs=
|
| 398 |
-
depth_control_scale, identity_control_scale, preset_status]
|
| 399 |
)
|
| 400 |
|
| 401 |
preset_btn_2.click(
|
| 402 |
fn=lambda: apply_preset("Premium Portrait"),
|
| 403 |
inputs=[],
|
| 404 |
-
outputs=
|
| 405 |
-
depth_control_scale, identity_control_scale, preset_status]
|
| 406 |
)
|
| 407 |
|
| 408 |
preset_btn_3.click(
|
| 409 |
fn=lambda: apply_preset("Balanced Portrait"),
|
| 410 |
inputs=[],
|
| 411 |
-
outputs=
|
| 412 |
-
depth_control_scale, identity_control_scale, preset_status]
|
| 413 |
)
|
| 414 |
|
| 415 |
preset_btn_4.click(
|
| 416 |
fn=lambda: apply_preset("Artistic Excellence"),
|
| 417 |
inputs=[],
|
| 418 |
-
outputs=
|
| 419 |
-
depth_control_scale, identity_control_scale, preset_status]
|
| 420 |
)
|
| 421 |
|
| 422 |
preset_btn_5.click(
|
| 423 |
fn=lambda: apply_preset("Style Focus"),
|
| 424 |
inputs=[],
|
| 425 |
-
outputs=
|
| 426 |
-
depth_control_scale, identity_control_scale, preset_status]
|
| 427 |
)
|
| 428 |
|
| 429 |
preset_btn_6.click(
|
| 430 |
fn=lambda: apply_preset("Subtle Enhancement"),
|
| 431 |
inputs=[],
|
| 432 |
-
outputs=
|
| 433 |
-
depth_control_scale, identity_control_scale, preset_status]
|
| 434 |
)
|
| 435 |
|
|
|
|
| 436 |
generate_btn.click(
|
| 437 |
fn=process_image,
|
| 438 |
inputs=[
|
| 439 |
input_image, prompt, negative_prompt, steps, guidance_scale,
|
| 440 |
-
depth_control_scale, identity_control_scale,
|
| 441 |
-
identity_preservation, strength, enable_color_matching,
|
| 442 |
consistency_mode, seed_input, enable_captions
|
| 443 |
],
|
| 444 |
outputs=[output_image, caption_output]
|
|
@@ -450,6 +465,5 @@ if __name__ == "__main__":
|
|
| 450 |
demo.launch(
|
| 451 |
server_name="0.0.0.0",
|
| 452 |
server_port=7860,
|
| 453 |
-
share=True,
|
| 454 |
show_api=True
|
| 455 |
)
|
|
|
|
| 27 |
preset["lora_scale"],
|
| 28 |
preset["depth_control_scale"],
|
| 29 |
preset["identity_control_scale"],
|
| 30 |
+
preset["expression_control_scale"], # <-- NEW
|
| 31 |
f"[APPLIED] {preset_name}\n{preset['description']}"
|
| 32 |
)
|
| 33 |
|
|
|
|
| 41 |
guidance_scale,
|
| 42 |
depth_control_scale,
|
| 43 |
identity_control_scale,
|
| 44 |
+
expression_control_scale, # <-- NEW
|
| 45 |
lora_scale,
|
| 46 |
identity_preservation,
|
| 47 |
strength,
|
|
|
|
| 64 |
guidance_scale=guidance_scale,
|
| 65 |
depth_control_scale=depth_control_scale,
|
| 66 |
identity_control_scale=identity_control_scale,
|
| 67 |
+
expression_control_scale=expression_control_scale, # <-- NEW
|
| 68 |
lora_scale=lora_scale,
|
| 69 |
identity_preservation=identity_preservation,
|
| 70 |
strength=strength,
|
|
|
|
| 109 |
status_text += f"- Custom Checkpoint (Horizon): {'[OK] Loaded' if converter.models_loaded['custom_checkpoint'] else '[OK] Using SDXL base'}\n"
|
| 110 |
status_text += f"- LORA (RetroArt): {'[OK] Loaded' if converter.models_loaded['lora'] else ' Disabled'}\n"
|
| 111 |
status_text += f"- InstantID: {'[OK] Loaded' if converter.models_loaded['instantid'] else ' Disabled'}\n"
|
| 112 |
+
status_text += f"- Zoe Depth: {'[OK] Loaded' if converter.models_loaded['zoe_depth'] else ' Fallback'}\n"
|
| 113 |
+
status_text += f"- OpenPose (Expression): {'[OK] Loaded' if converter.models_loaded.get('openpose', False) else ' Disabled'}\n" # <-- NEW
|
| 114 |
status_text += f"- IP-Adapter (Face Embeddings): {'[OK] Loaded' if converter.models_loaded.get('ip_adapter', False) else ' Keypoints only'}\n"
|
| 115 |
return status_text
|
| 116 |
return "**Model status unavailable**"
|
|
|
|
| 178 |
**[CONFIG] Advanced Configuration:**
|
| 179 |
- Pipeline: **Img2Img** (structure preservation)
|
| 180 |
- Face System: **CLIP + InsightFace** (dual embeddings)
|
| 181 |
+
- **[NEW] Expression Control:** OpenPose-Face (68 keypoints)
|
| 182 |
- **[ADVANCED] Enhanced Resampler:** 10 layers, 20 heads (+3-5% quality)
|
| 183 |
- **[ADVANCED] Adaptive Attention:** Context-aware scaling (+2-3% quality)
|
| 184 |
- **[ADVANCED] Multi-Scale Processing:** 3-scale face analysis (+1-2% quality)
|
|
|
|
| 199 |
|
| 200 |
prompt = gr.Textbox(
|
| 201 |
label="Prompt (trigger word auto-added)",
|
| 202 |
+
value="",
|
| 203 |
lines=3,
|
| 204 |
info=f"'{TRIGGER_WORD}' will be automatically added"
|
| 205 |
)
|
| 206 |
|
| 207 |
negative_prompt = gr.Textbox(
|
| 208 |
label="Negative Prompt",
|
| 209 |
+
value="",
|
| 210 |
lines=2
|
| 211 |
)
|
| 212 |
|
|
|
|
| 285 |
label="InstantID ControlNet Scale (facial keypoints structure)"
|
| 286 |
)
|
| 287 |
|
| 288 |
+
# --- NEW SLIDER ---
|
| 289 |
+
expression_control_scale = gr.Slider(
|
| 290 |
+
minimum=0.1,
|
| 291 |
+
maximum=1.2,
|
| 292 |
+
value=DEFAULT_PARAMS['expression_control_scale'],
|
| 293 |
+
step=0.05,
|
| 294 |
+
label="[NEW] Expression Control Scale (OpenPose shape)"
|
| 295 |
+
)
|
| 296 |
+
# --- END NEW SLIDER ---
|
| 297 |
+
|
| 298 |
identity_preservation = gr.Slider(
|
| 299 |
minimum=0.3,
|
| 300 |
maximum=2.0,
|
|
|
|
| 344 |
### Tips for Maximum Quality Results:
|
| 345 |
|
| 346 |
**[OPTIMIZATIONS] Advanced Optimizations Active:**
|
| 347 |
+
- **[NEW] Expression Control:** OpenPose-Face (68 keypoints)
|
| 348 |
- **Enhanced Resampler:** 10 layers, 20 heads (+3-5% quality)
|
| 349 |
- **Adaptive Attention:** Context-aware scaling (+2-3% quality)
|
| 350 |
- **Multi-Scale Processing:** 3-scale face analysis (+1-2% quality)
|
|
|
|
| 367 |
**[ADAPTIVE] Automatic Adjustments:**
|
| 368 |
- Small faces (< 50K px): Boosts identity preservation to 1.8
|
| 369 |
- Low confidence (< 80%): Increases identity control to 0.9
|
| 370 |
+
- Profile views (> 20° yaw): Enhances preservation to 1.7
|
| 371 |
- Good quality faces: Uses your selected parameters
|
| 372 |
|
| 373 |
**[PARAMETERS] Parameter Relationships:**
|
|
|
|
| 383 |
- Validates parameter combinations for predictability
|
| 384 |
- Prevents identity-LORA conflicts
|
| 385 |
- Keeps CFG in optimal LCM range
|
| 386 |
+
- Balances ControlNet scales (now 3 models, max 2.0 total)
|
| 387 |
- Recommended: Always ON
|
| 388 |
|
| 389 |
**[SEED] Reproducibility:**
|
|
|
|
| 406 |
- Resolution: Auto-optimized to 896x1152 or 832x1216
|
| 407 |
""")
|
| 408 |
|
| 409 |
+
# --- MODIFIED: Preset button click events (added expression_control_scale) ---
|
| 410 |
+
all_sliders = [strength, guidance_scale, identity_preservation, lora_scale,
|
| 411 |
+
depth_control_scale, identity_control_scale, expression_control_scale,
|
| 412 |
+
preset_status]
|
| 413 |
+
|
| 414 |
preset_btn_1.click(
|
| 415 |
fn=lambda: apply_preset("Ultra Fidelity"),
|
| 416 |
inputs=[],
|
| 417 |
+
outputs=all_sliders
|
|
|
|
| 418 |
)
|
| 419 |
|
| 420 |
preset_btn_2.click(
|
| 421 |
fn=lambda: apply_preset("Premium Portrait"),
|
| 422 |
inputs=[],
|
| 423 |
+
outputs=all_sliders
|
|
|
|
| 424 |
)
|
| 425 |
|
| 426 |
preset_btn_3.click(
|
| 427 |
fn=lambda: apply_preset("Balanced Portrait"),
|
| 428 |
inputs=[],
|
| 429 |
+
outputs=all_sliders
|
|
|
|
| 430 |
)
|
| 431 |
|
| 432 |
preset_btn_4.click(
|
| 433 |
fn=lambda: apply_preset("Artistic Excellence"),
|
| 434 |
inputs=[],
|
| 435 |
+
outputs=all_sliders
|
|
|
|
| 436 |
)
|
| 437 |
|
| 438 |
preset_btn_5.click(
|
| 439 |
fn=lambda: apply_preset("Style Focus"),
|
| 440 |
inputs=[],
|
| 441 |
+
outputs=all_sliders
|
|
|
|
| 442 |
)
|
| 443 |
|
| 444 |
preset_btn_6.click(
|
| 445 |
fn=lambda: apply_preset("Subtle Enhancement"),
|
| 446 |
inputs=[],
|
| 447 |
+
outputs=all_sliders
|
|
|
|
| 448 |
)
|
| 449 |
|
| 450 |
+
# --- MODIFIED: generate_btn.click (added expression_control_scale) ---
|
| 451 |
generate_btn.click(
|
| 452 |
fn=process_image,
|
| 453 |
inputs=[
|
| 454 |
input_image, prompt, negative_prompt, steps, guidance_scale,
|
| 455 |
+
depth_control_scale, identity_control_scale, expression_control_scale,
|
| 456 |
+
lora_scale, identity_preservation, strength, enable_color_matching,
|
| 457 |
consistency_mode, seed_input, enable_captions
|
| 458 |
],
|
| 459 |
outputs=[output_image, caption_output]
|
|
|
|
| 465 |
demo.launch(
|
| 466 |
server_name="0.0.0.0",
|
| 467 |
server_port=7860,
|
|
|
|
| 468 |
show_api=True
|
| 469 |
)
|