Update app.py
Browse files
app.py
CHANGED
|
@@ -34,7 +34,7 @@ MODEL_CONFIGS = {
|
|
| 34 |
"cfg": 7.0,
|
| 35 |
"sampler": "DPM++ 2M Karras"
|
| 36 |
},
|
| 37 |
-
"description": "WAI NSFW Illustrious v8.0 -
|
| 38 |
},
|
| 39 |
"wai_nsfw_illustrious_v90": {
|
| 40 |
"repo_id": "John6666/wai-nsfw-illustrious-v90-sdxl",
|
|
@@ -46,7 +46,7 @@ MODEL_CONFIGS = {
|
|
| 46 |
"cfg": 7.0,
|
| 47 |
"sampler": "DPM++ 2M Karras"
|
| 48 |
},
|
| 49 |
-
"description": "WAI NSFW Illustrious v9.0 -
|
| 50 |
},
|
| 51 |
"wai_nsfw_illustrious_v110": {
|
| 52 |
"repo_id": "John6666/wai-nsfw-illustrious-v110-sdxl",
|
|
@@ -58,7 +58,7 @@ MODEL_CONFIGS = {
|
|
| 58 |
"cfg": 7.5,
|
| 59 |
"sampler": "DPM++ 2M Karras"
|
| 60 |
},
|
| 61 |
-
"description": "WAI NSFW Illustrious v11.0 -
|
| 62 |
},
|
| 63 |
"sdxl_base": {
|
| 64 |
"repo_id": "stabilityai/stable-diffusion-xl-base-1.0",
|
|
@@ -70,7 +70,7 @@ MODEL_CONFIGS = {
|
|
| 70 |
"cfg": 7.5,
|
| 71 |
"sampler": "Default"
|
| 72 |
},
|
| 73 |
-
"description": "Stable Diffusion XL Base 1.0 -
|
| 74 |
},
|
| 75 |
"realistic_vision": {
|
| 76 |
"repo_id": "SG161222/RealVisXL_V4.0",
|
|
@@ -82,7 +82,7 @@ MODEL_CONFIGS = {
|
|
| 82 |
"cfg": 7.5,
|
| 83 |
"sampler": "Default"
|
| 84 |
},
|
| 85 |
-
"description": "RealVisXL V4.0 -
|
| 86 |
},
|
| 87 |
"anime_xl": {
|
| 88 |
"repo_id": "Linaqruf/animagine-xl-3.1",
|
|
@@ -94,7 +94,7 @@ MODEL_CONFIGS = {
|
|
| 94 |
"cfg": 7.0,
|
| 95 |
"sampler": "Default"
|
| 96 |
},
|
| 97 |
-
"description": "Animagine XL 3.1 -
|
| 98 |
},
|
| 99 |
"juggernaut_xl": {
|
| 100 |
"repo_id": "RunDiffusion/Juggernaut-XL-v9",
|
|
@@ -106,7 +106,7 @@ MODEL_CONFIGS = {
|
|
| 106 |
"cfg": 7.5,
|
| 107 |
"sampler": "Default"
|
| 108 |
},
|
| 109 |
-
"description": "Juggernaut XL v9 -
|
| 110 |
}
|
| 111 |
}
|
| 112 |
|
|
@@ -148,43 +148,43 @@ OPTIONAL_LORAS = {
|
|
| 148 |
"repo_id": None,
|
| 149 |
"weight": 0.0,
|
| 150 |
"trigger_words": "",
|
| 151 |
-
"description": "
|
| 152 |
},
|
| 153 |
"Offset Noise": {
|
| 154 |
"repo_id": "stabilityai/stable-diffusion-xl-offset-example-lora",
|
| 155 |
"weight": 0.7,
|
| 156 |
"trigger_words": "high contrast, dramatic lighting",
|
| 157 |
-
"description": "
|
| 158 |
},
|
| 159 |
"LCM LoRA": {
|
| 160 |
"repo_id": "latent-consistency/lcm-lora-sdxl",
|
| 161 |
"weight": 0.8,
|
| 162 |
"trigger_words": "high quality",
|
| 163 |
-
"description": "
|
| 164 |
},
|
| 165 |
"Pixel Art": {
|
| 166 |
"repo_id": "nerijs/pixel-art-xl",
|
| 167 |
"weight": 0.9,
|
| 168 |
"trigger_words": "pixel art style, 8bit, retro",
|
| 169 |
-
"description": "
|
| 170 |
},
|
| 171 |
"Watercolor": {
|
| 172 |
"repo_id": "ostris/watercolor-style-lora-sdxl",
|
| 173 |
"weight": 0.8,
|
| 174 |
"trigger_words": "watercolor painting, soft colors",
|
| 175 |
-
"description": "
|
| 176 |
},
|
| 177 |
"Sketch": {
|
| 178 |
"repo_id": "ostris/crayon-style-lora-sdxl",
|
| 179 |
"weight": 0.7,
|
| 180 |
"trigger_words": "sketch style, pencil drawing",
|
| 181 |
-
"description": "
|
| 182 |
},
|
| 183 |
"Portrait": {
|
| 184 |
"repo_id": "ostris/face-helper-sdxl-lora",
|
| 185 |
"weight": 0.8,
|
| 186 |
"trigger_words": "portrait, beautiful face, detailed eyes",
|
| 187 |
-
"description": "
|
| 188 |
}
|
| 189 |
}
|
| 190 |
|
|
@@ -482,11 +482,11 @@ def generate_image(
|
|
| 482 |
return (
|
| 483 |
image,
|
| 484 |
metadata_str,
|
| 485 |
-
f"✅
|
| 486 |
)
|
| 487 |
|
| 488 |
except Exception as e:
|
| 489 |
-
error_msg = f"
|
| 490 |
print(f"❌ {error_msg}")
|
| 491 |
return None, error_msg, error_msg
|
| 492 |
|
|
@@ -517,12 +517,12 @@ def create_interface():
|
|
| 517 |
margin: 10px 0;
|
| 518 |
}
|
| 519 |
""",
|
| 520 |
-
title="AI
|
| 521 |
) as demo:
|
| 522 |
|
| 523 |
gr.Markdown("""
|
| 524 |
-
# 🎨 AI
|
| 525 |
-
###
|
| 526 |
""", elem_classes=["model-card"])
|
| 527 |
|
| 528 |
with gr.Row():
|
|
@@ -531,42 +531,42 @@ def create_interface():
|
|
| 531 |
|
| 532 |
# 模型选择
|
| 533 |
with gr.Group(elem_classes=["control-section"]):
|
| 534 |
-
gr.Markdown("### 📦
|
| 535 |
model_dropdown = gr.Dropdown(
|
| 536 |
choices=[(config["description"], key) for key, config in MODEL_CONFIGS.items()],
|
| 537 |
value=DEFAULT_MODEL_KEY,
|
| 538 |
-
label="
|
| 539 |
-
info="
|
| 540 |
)
|
| 541 |
model_info = gr.Markdown(MODEL_CONFIGS[DEFAULT_MODEL_KEY]["description"])
|
| 542 |
|
| 543 |
# 提示词输入
|
| 544 |
with gr.Group(elem_classes=["control-section"]):
|
| 545 |
-
gr.Markdown("### ✍️
|
| 546 |
prompt_input = gr.Textbox(
|
| 547 |
-
label="
|
| 548 |
-
placeholder="
|
| 549 |
lines=4,
|
| 550 |
max_lines=20
|
| 551 |
)
|
| 552 |
|
| 553 |
negative_prompt_input = gr.Textbox(
|
| 554 |
-
label="
|
| 555 |
-
placeholder="
|
| 556 |
lines=3,
|
| 557 |
max_lines=15
|
| 558 |
)
|
| 559 |
|
| 560 |
style_radio = gr.Radio(
|
| 561 |
choices=list(STYLE_PROMPTS.keys()),
|
| 562 |
-
label="
|
| 563 |
value="None",
|
| 564 |
-
info="
|
| 565 |
)
|
| 566 |
|
| 567 |
# 基础参数
|
| 568 |
with gr.Group(elem_classes=["control-section"]):
|
| 569 |
-
gr.Markdown("### ⚙️
|
| 570 |
|
| 571 |
with gr.Row():
|
| 572 |
seed_input = gr.Slider(
|
|
@@ -574,7 +574,7 @@ def create_interface():
|
|
| 574 |
maximum=99999999,
|
| 575 |
step=1,
|
| 576 |
value=DEFAULT_SEED,
|
| 577 |
-
label="
|
| 578 |
)
|
| 579 |
|
| 580 |
with gr.Row():
|
|
@@ -583,14 +583,14 @@ def create_interface():
|
|
| 583 |
maximum=1536,
|
| 584 |
step=64,
|
| 585 |
value=DEFAULT_WIDTH,
|
| 586 |
-
label="
|
| 587 |
)
|
| 588 |
height_input = gr.Slider(
|
| 589 |
minimum=512,
|
| 590 |
maximum=1536,
|
| 591 |
step=64,
|
| 592 |
value=DEFAULT_HEIGHT,
|
| 593 |
-
label="
|
| 594 |
)
|
| 595 |
|
| 596 |
with gr.Row():
|
|
@@ -599,7 +599,7 @@ def create_interface():
|
|
| 599 |
maximum=100,
|
| 600 |
step=1,
|
| 601 |
value=DEFAULT_STEPS,
|
| 602 |
-
label="
|
| 603 |
)
|
| 604 |
cfg_slider = gr.Slider(
|
| 605 |
minimum=1.0,
|
|
@@ -611,20 +611,20 @@ def create_interface():
|
|
| 611 |
|
| 612 |
# LoRA配置
|
| 613 |
with gr.Group(elem_classes=["control-section"]):
|
| 614 |
-
gr.Markdown("### 🎭 LoRA
|
| 615 |
|
| 616 |
use_fixed_loras = gr.Checkbox(
|
| 617 |
-
label="
|
| 618 |
value=True,
|
| 619 |
-
info="
|
| 620 |
)
|
| 621 |
|
| 622 |
lora_dropdown = gr.Dropdown(
|
| 623 |
choices=list(OPTIONAL_LORAS.keys()),
|
| 624 |
-
label="
|
| 625 |
value=["None"],
|
| 626 |
multiselect=True,
|
| 627 |
-
info="
|
| 628 |
)
|
| 629 |
|
| 630 |
lora_scale_slider = gr.Slider(
|
|
@@ -632,34 +632,34 @@ def create_interface():
|
|
| 632 |
maximum=1.5,
|
| 633 |
step=0.05,
|
| 634 |
value=DEFAULT_LORA_SCALE,
|
| 635 |
-
label="LoRA
|
| 636 |
)
|
| 637 |
|
| 638 |
# 生成按钮
|
| 639 |
generate_btn = gr.Button(
|
| 640 |
-
"✨
|
| 641 |
variant="primary",
|
| 642 |
size="lg"
|
| 643 |
)
|
| 644 |
|
| 645 |
status_text = gr.Textbox(
|
| 646 |
-
label="
|
| 647 |
-
value="
|
| 648 |
interactive=False
|
| 649 |
)
|
| 650 |
|
| 651 |
# 右侧 - 输出
|
| 652 |
with gr.Column(scale=2):
|
| 653 |
image_output = gr.Image(
|
| 654 |
-
label="
|
| 655 |
height=600,
|
| 656 |
format="webp"
|
| 657 |
)
|
| 658 |
|
| 659 |
-
gr.Markdown("
|
| 660 |
|
| 661 |
metadata_output = gr.Textbox(
|
| 662 |
-
label="
|
| 663 |
lines=15,
|
| 664 |
max_lines=25
|
| 665 |
)
|
|
|
|
| 34 |
"cfg": 7.0,
|
| 35 |
"sampler": "DPM++ 2M Karras"
|
| 36 |
},
|
| 37 |
+
"description": "WAI NSFW Illustrious v8.0 - High-quality illustration-style mockups"
|
| 38 |
},
|
| 39 |
"wai_nsfw_illustrious_v90": {
|
| 40 |
"repo_id": "John6666/wai-nsfw-illustrious-v90-sdxl",
|
|
|
|
| 46 |
"cfg": 7.0,
|
| 47 |
"sampler": "DPM++ 2M Karras"
|
| 48 |
},
|
| 49 |
+
"description": "WAI NSFW Illustrious v9.0 - Latest version"
|
| 50 |
},
|
| 51 |
"wai_nsfw_illustrious_v110": {
|
| 52 |
"repo_id": "John6666/wai-nsfw-illustrious-v110-sdxl",
|
|
|
|
| 58 |
"cfg": 7.5,
|
| 59 |
"sampler": "DPM++ 2M Karras"
|
| 60 |
},
|
| 61 |
+
"description": "WAI NSFW Illustrious v11.0 - Enhanced version"
|
| 62 |
},
|
| 63 |
"sdxl_base": {
|
| 64 |
"repo_id": "stabilityai/stable-diffusion-xl-base-1.0",
|
|
|
|
| 70 |
"cfg": 7.5,
|
| 71 |
"sampler": "Default"
|
| 72 |
},
|
| 73 |
+
"description": "Stable Diffusion XL Base 1.0 - Official base model"
|
| 74 |
},
|
| 75 |
"realistic_vision": {
|
| 76 |
"repo_id": "SG161222/RealVisXL_V4.0",
|
|
|
|
| 82 |
"cfg": 7.5,
|
| 83 |
"sampler": "Default"
|
| 84 |
},
|
| 85 |
+
"description": "RealVisXL V4.0 - High-quality realistic style"
|
| 86 |
},
|
| 87 |
"anime_xl": {
|
| 88 |
"repo_id": "Linaqruf/animagine-xl-3.1",
|
|
|
|
| 94 |
"cfg": 7.0,
|
| 95 |
"sampler": "Default"
|
| 96 |
},
|
| 97 |
+
"description": "Animagine XL 3.1 - Anime style"
|
| 98 |
},
|
| 99 |
"juggernaut_xl": {
|
| 100 |
"repo_id": "RunDiffusion/Juggernaut-XL-v9",
|
|
|
|
| 106 |
"cfg": 7.5,
|
| 107 |
"sampler": "Default"
|
| 108 |
},
|
| 109 |
+
"description": "Juggernaut XL v9 - Universal high-quality models"
|
| 110 |
}
|
| 111 |
}
|
| 112 |
|
|
|
|
| 148 |
"repo_id": None,
|
| 149 |
"weight": 0.0,
|
| 150 |
"trigger_words": "",
|
| 151 |
+
"description": "No additional LoRA"
|
| 152 |
},
|
| 153 |
"Offset Noise": {
|
| 154 |
"repo_id": "stabilityai/stable-diffusion-xl-offset-example-lora",
|
| 155 |
"weight": 0.7,
|
| 156 |
"trigger_words": "high contrast, dramatic lighting",
|
| 157 |
+
"description": "Enhance contrast and lighting effects"
|
| 158 |
},
|
| 159 |
"LCM LoRA": {
|
| 160 |
"repo_id": "latent-consistency/lcm-lora-sdxl",
|
| 161 |
"weight": 0.8,
|
| 162 |
"trigger_words": "high quality",
|
| 163 |
+
"description": "Rapid Generation Mode"
|
| 164 |
},
|
| 165 |
"Pixel Art": {
|
| 166 |
"repo_id": "nerijs/pixel-art-xl",
|
| 167 |
"weight": 0.9,
|
| 168 |
"trigger_words": "pixel art style, 8bit, retro",
|
| 169 |
+
"description": "Pixel art style"
|
| 170 |
},
|
| 171 |
"Watercolor": {
|
| 172 |
"repo_id": "ostris/watercolor-style-lora-sdxl",
|
| 173 |
"weight": 0.8,
|
| 174 |
"trigger_words": "watercolor painting, soft colors",
|
| 175 |
+
"description": "Watercolor style"
|
| 176 |
},
|
| 177 |
"Sketch": {
|
| 178 |
"repo_id": "ostris/crayon-style-lora-sdxl",
|
| 179 |
"weight": 0.7,
|
| 180 |
"trigger_words": "sketch style, pencil drawing",
|
| 181 |
+
"description": "Sketch Style"
|
| 182 |
},
|
| 183 |
"Portrait": {
|
| 184 |
"repo_id": "ostris/face-helper-sdxl-lora",
|
| 185 |
"weight": 0.8,
|
| 186 |
"trigger_words": "portrait, beautiful face, detailed eyes",
|
| 187 |
+
"description": "Portrait and face enhancement"
|
| 188 |
}
|
| 189 |
}
|
| 190 |
|
|
|
|
| 482 |
return (
|
| 483 |
image,
|
| 484 |
metadata_str,
|
| 485 |
+
f"✅ Generate successfully! Seed: {seed}"
|
| 486 |
)
|
| 487 |
|
| 488 |
except Exception as e:
|
| 489 |
+
error_msg = f"Build Failure: {str(e)}"
|
| 490 |
print(f"❌ {error_msg}")
|
| 491 |
return None, error_msg, error_msg
|
| 492 |
|
|
|
|
| 517 |
margin: 10px 0;
|
| 518 |
}
|
| 519 |
""",
|
| 520 |
+
title="AI Image Generator - Illustrious XL Multi-model version"
|
| 521 |
) as demo:
|
| 522 |
|
| 523 |
gr.Markdown("""
|
| 524 |
+
# 🎨 AI Image Generator - Illustrious XL Multi-Model Edition
|
| 525 |
+
### Flexible switching between multiple SDXL models | Flexible LoRa combinations | Optimized parameter configuration
|
| 526 |
""", elem_classes=["model-card"])
|
| 527 |
|
| 528 |
with gr.Row():
|
|
|
|
| 531 |
|
| 532 |
# 模型选择
|
| 533 |
with gr.Group(elem_classes=["control-section"]):
|
| 534 |
+
gr.Markdown("### 📦 Model selection")
|
| 535 |
model_dropdown = gr.Dropdown(
|
| 536 |
choices=[(config["description"], key) for key, config in MODEL_CONFIGS.items()],
|
| 537 |
value=DEFAULT_MODEL_KEY,
|
| 538 |
+
label="Basic Model",
|
| 539 |
+
info="Choose different models to get different styles"
|
| 540 |
)
|
| 541 |
model_info = gr.Markdown(MODEL_CONFIGS[DEFAULT_MODEL_KEY]["description"])
|
| 542 |
|
| 543 |
# 提示词输入
|
| 544 |
with gr.Group(elem_classes=["control-section"]):
|
| 545 |
+
gr.Markdown("### ✍️ Prompt")
|
| 546 |
prompt_input = gr.Textbox(
|
| 547 |
+
label="Prompt",
|
| 548 |
+
placeholder="Describe the image you want to generate...",
|
| 549 |
lines=4,
|
| 550 |
max_lines=20
|
| 551 |
)
|
| 552 |
|
| 553 |
negative_prompt_input = gr.Textbox(
|
| 554 |
+
label="Negative Prompt(Leave blank to use the model default)",
|
| 555 |
+
placeholder="The recommended negative prompt words of the selected model will be automatically used...",
|
| 556 |
lines=3,
|
| 557 |
max_lines=15
|
| 558 |
)
|
| 559 |
|
| 560 |
style_radio = gr.Radio(
|
| 561 |
choices=list(STYLE_PROMPTS.keys()),
|
| 562 |
+
label="Style Template",
|
| 563 |
value="None",
|
| 564 |
+
info="Will be automatically added before the prompt word"
|
| 565 |
)
|
| 566 |
|
| 567 |
# 基础参数
|
| 568 |
with gr.Group(elem_classes=["control-section"]):
|
| 569 |
+
gr.Markdown("### ⚙️ Basic Parameters")
|
| 570 |
|
| 571 |
with gr.Row():
|
| 572 |
seed_input = gr.Slider(
|
|
|
|
| 574 |
maximum=99999999,
|
| 575 |
step=1,
|
| 576 |
value=DEFAULT_SEED,
|
| 577 |
+
label="Seed (-1=Random)"
|
| 578 |
)
|
| 579 |
|
| 580 |
with gr.Row():
|
|
|
|
| 583 |
maximum=1536,
|
| 584 |
step=64,
|
| 585 |
value=DEFAULT_WIDTH,
|
| 586 |
+
label="Width"
|
| 587 |
)
|
| 588 |
height_input = gr.Slider(
|
| 589 |
minimum=512,
|
| 590 |
maximum=1536,
|
| 591 |
step=64,
|
| 592 |
value=DEFAULT_HEIGHT,
|
| 593 |
+
label="High"
|
| 594 |
)
|
| 595 |
|
| 596 |
with gr.Row():
|
|
|
|
| 599 |
maximum=100,
|
| 600 |
step=1,
|
| 601 |
value=DEFAULT_STEPS,
|
| 602 |
+
label="Sampling Steps"
|
| 603 |
)
|
| 604 |
cfg_slider = gr.Slider(
|
| 605 |
minimum=1.0,
|
|
|
|
| 611 |
|
| 612 |
# LoRA配置
|
| 613 |
with gr.Group(elem_classes=["control-section"]):
|
| 614 |
+
gr.Markdown("### 🎭 LoRA Configuration")
|
| 615 |
|
| 616 |
use_fixed_loras = gr.Checkbox(
|
| 617 |
+
label="Fixed LoRA enhancement (quality + details)",
|
| 618 |
value=True,
|
| 619 |
+
info="Automatically load quality and detail enhancements for LoRA"
|
| 620 |
)
|
| 621 |
|
| 622 |
lora_dropdown = gr.Dropdown(
|
| 623 |
choices=list(OPTIONAL_LORAS.keys()),
|
| 624 |
+
label="Additional LoRA (multiple selections possible)",
|
| 625 |
value=["None"],
|
| 626 |
multiselect=True,
|
| 627 |
+
info="Select additional styles LoRA"
|
| 628 |
)
|
| 629 |
|
| 630 |
lora_scale_slider = gr.Slider(
|
|
|
|
| 632 |
maximum=1.5,
|
| 633 |
step=0.05,
|
| 634 |
value=DEFAULT_LORA_SCALE,
|
| 635 |
+
label="LoRA Strength"
|
| 636 |
)
|
| 637 |
|
| 638 |
# 生成按钮
|
| 639 |
generate_btn = gr.Button(
|
| 640 |
+
"✨ Generat",
|
| 641 |
variant="primary",
|
| 642 |
size="lg"
|
| 643 |
)
|
| 644 |
|
| 645 |
status_text = gr.Textbox(
|
| 646 |
+
label="Status",
|
| 647 |
+
value="Ready",
|
| 648 |
interactive=False
|
| 649 |
)
|
| 650 |
|
| 651 |
# 右侧 - 输出
|
| 652 |
with gr.Column(scale=2):
|
| 653 |
image_output = gr.Image(
|
| 654 |
+
label="Generated image",
|
| 655 |
height=600,
|
| 656 |
format="webp"
|
| 657 |
)
|
| 658 |
|
| 659 |
+
gr.Markdown("**Right click on the image to download**")
|
| 660 |
|
| 661 |
metadata_output = gr.Textbox(
|
| 662 |
+
label="Generated metadata",
|
| 663 |
lines=15,
|
| 664 |
max_lines=25
|
| 665 |
)
|