lllyasviel commited on
Commit
e848396
·
1 Parent(s): 515ca04
Files changed (2) hide show
  1. modules/sdxl_styles.py +34 -0
  2. webui.py +20 -7
modules/sdxl_styles.py CHANGED
@@ -530,6 +530,40 @@ styles = [
530
 
531
  styles = {k['name']: (k['prompt'], k['negative_prompt']) for k in styles}
532
  default_style = styles['sai-base']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
 
534
 
535
  def apply_style(style, positive, negative):
 
530
 
531
  styles = {k['name']: (k['prompt'], k['negative_prompt']) for k in styles}
532
  default_style = styles['sai-base']
533
+ style_keys = list(styles.keys())
534
+
535
+
536
+ SD_XL_BASE_RATIOS = {
537
+ "0.5": (704, 1408),
538
+ "0.52": (704, 1344),
539
+ "0.57": (768, 1344),
540
+ "0.6": (768, 1280),
541
+ "0.68": (832, 1216),
542
+ "0.72": (832, 1152),
543
+ "0.78": (896, 1152),
544
+ "0.82": (896, 1088),
545
+ "0.88": (960, 1088),
546
+ "0.94": (960, 1024),
547
+ "1.0": (1024, 1024),
548
+ "1.07": (1024, 960),
549
+ "1.13": (1088, 960),
550
+ "1.21": (1088, 896),
551
+ "1.29": (1152, 896),
552
+ "1.38": (1152, 832),
553
+ "1.46": (1216, 832),
554
+ "1.67": (1280, 768),
555
+ "1.75": (1344, 768),
556
+ "1.91": (1344, 704),
557
+ "2.0": (1408, 704),
558
+ "2.09": (1472, 704),
559
+ "2.4": (1536, 640),
560
+ "2.5": (1600, 640),
561
+ "2.89": (1664, 576),
562
+ "3.0": (1728, 576),
563
+ }
564
+
565
+
566
+ aspect_ratios = {str(v[0])+'×'+str(v[1]):v for k, v in SD_XL_BASE_RATIOS.items()}
567
 
568
 
569
  def apply_style(style, positive, negative):
webui.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
 
3
- from modules.sdxl_styles import apply_style
4
- from modules.default_pipeline import process
5
 
6
 
7
  def generate_clicked(positive_prompt):
@@ -18,7 +18,7 @@ def generate_clicked(positive_prompt):
18
  block = gr.Blocks()
19
  with block:
20
  with gr.Row():
21
- with gr.Column(scale=0.7):
22
  gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', height=768)
23
  with gr.Row():
24
  with gr.Column(scale=0.85):
@@ -27,9 +27,22 @@ with block:
27
  run_button = gr.Button(label="Generate", value="Generate")
28
  with gr.Row():
29
  advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=False)
30
- with gr.Column(scale=0.3):
31
- with gr.Group():
32
- gr.Textbox()
33
- run_button.click(fn=generate_clicked, inputs=[prompt], outputs=[gallery])
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  block.launch()
 
1
  import gradio as gr
2
 
3
+ from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
4
+ # from modules.default_pipeline import process
5
 
6
 
7
  def generate_clicked(positive_prompt):
 
18
  block = gr.Blocks()
19
  with block:
20
  with gr.Row():
21
+ with gr.Column():
22
  gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', height=768)
23
  with gr.Row():
24
  with gr.Column(scale=0.85):
 
27
  run_button = gr.Button(label="Generate", value="Generate")
28
  with gr.Row():
29
  advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=False)
30
+ with gr.Column(scale=0.5, visible=False) as right_col:
31
+ with gr.Tab(label='Generator Setting'):
32
+ performance_selction = gr.Radio(label='Performance', choices=['Speed', 'Quality'], value='Speed')
33
+ aspect_ratios_selction = gr.Radio(label='Aspect Ratios', choices=list(aspect_ratios.keys()),
34
+ value='1152×896')
35
+ image_number = gr.Slider(label='Image Number', minimum=1, maximum=32, step=1, value=2)
36
+ image_seed = gr.Number(label='Random Seed', value=-1, precision=0)
37
+ negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.")
38
+ with gr.Tab(label='Image Style'):
39
+ style_selction = gr.Radio(show_label=False, container=True,
40
+ choices=style_keys, value='cinematic-default')
41
+ advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, right_col)
42
+ ctrls = [
43
+ prompt, negative_prompt, style_selction,
44
+ performance_selction, aspect_ratios_selction, image_number, image_seed
45
+ ]
46
+ run_button.click(fn=generate_clicked, inputs=ctrls, outputs=[gallery])
47
 
48
  block.launch()