This commit is contained in:
lvmin 2023-08-10 20:51:53 -07:00
parent 4421506b67
commit 80ce0abf9a
2 changed files with 54 additions and 7 deletions

View File

@ -530,6 +530,40 @@ styles = [
styles = {k['name']: (k['prompt'], k['negative_prompt']) for k in styles}
default_style = styles['sai-base']
style_keys = list(styles.keys())
SD_XL_BASE_RATIOS = {
"0.5": (704, 1408),
"0.52": (704, 1344),
"0.57": (768, 1344),
"0.6": (768, 1280),
"0.68": (832, 1216),
"0.72": (832, 1152),
"0.78": (896, 1152),
"0.82": (896, 1088),
"0.88": (960, 1088),
"0.94": (960, 1024),
"1.0": (1024, 1024),
"1.07": (1024, 960),
"1.13": (1088, 960),
"1.21": (1088, 896),
"1.29": (1152, 896),
"1.38": (1152, 832),
"1.46": (1216, 832),
"1.67": (1280, 768),
"1.75": (1344, 768),
"1.91": (1344, 704),
"2.0": (1408, 704),
"2.09": (1472, 704),
"2.4": (1536, 640),
"2.5": (1600, 640),
"2.89": (1664, 576),
"3.0": (1728, 576),
}
aspect_ratios = {str(v[0])+'×'+str(v[1]):v for k, v in SD_XL_BASE_RATIOS.items()}
def apply_style(style, positive, negative):

View File

@ -1,7 +1,7 @@
import gradio as gr
from modules.sdxl_styles import apply_style
from modules.default_pipeline import process
from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
# from modules.default_pipeline import process
def generate_clicked(positive_prompt):
@ -18,7 +18,7 @@ def generate_clicked(positive_prompt):
block = gr.Blocks()
with block:
with gr.Row():
with gr.Column(scale=0.7):
with gr.Column():
gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', height=768)
with gr.Row():
with gr.Column(scale=0.85):
@ -27,9 +27,22 @@ with block:
run_button = gr.Button(label="Generate", value="Generate")
with gr.Row():
advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=False)
with gr.Column(scale=0.3):
with gr.Group():
gr.Textbox()
run_button.click(fn=generate_clicked, inputs=[prompt], outputs=[gallery])
with gr.Column(scale=0.5, visible=False) as right_col:
with gr.Tab(label='Generator Setting'):
performance_selction = gr.Radio(label='Performance', choices=['Speed', 'Quality'], value='Speed')
aspect_ratios_selction = gr.Radio(label='Aspect Ratios', choices=list(aspect_ratios.keys()),
value='1152×896')
image_number = gr.Slider(label='Image Number', minimum=1, maximum=32, step=1, value=2)
image_seed = gr.Number(label='Random Seed', value=-1, precision=0)
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.")
with gr.Tab(label='Image Style'):
style_selction = gr.Radio(show_label=False, container=True,
choices=style_keys, value='cinematic-default')
advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, right_col)
ctrls = [
prompt, negative_prompt, style_selction,
performance_selction, aspect_ratios_selction, image_number, image_seed
]
run_button.click(fn=generate_clicked, inputs=ctrls, outputs=[gallery])
block.launch()