alexander00001 commited on
Commit
2ac0b71
·
verified ·
1 Parent(s): 9e9fcb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -46
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": "不使用额外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": "增强对比度和光照效果"
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"✅ 生成成功! 种子: {seed}"
486
  )
487
 
488
  except Exception as e:
489
- error_msg = f"生成失败: {str(e)}"
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图像生成器 - Illustrious XL多模型版"
521
  ) as demo:
522
 
523
  gr.Markdown("""
524
- # 🎨 AI图像生成器 - Illustrious XL多模型版
525
- ### 支持多种SDXL模型自由切换 | 灵活的LoRA组合 | 优化的参数配置
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="种子 (-1=随机)"
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="启用固定LoRA增强(质量+细节)",
618
  value=True,
619
- info="自动加载质量和细节增强LoRA"
620
  )
621
 
622
  lora_dropdown = gr.Dropdown(
623
  choices=list(OPTIONAL_LORAS.keys()),
624
- label="额外LoRA(可多选)",
625
  value=["None"],
626
  multiselect=True,
627
- info="选择额外的风格LoRA"
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="生成元数据 (JSON)",
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
  )