Update webui.py
Browse files
webui.py
CHANGED
@@ -86,7 +86,7 @@ def generate_clicked(task):
|
|
86 |
|
87 |
reload_javascript()
|
88 |
|
89 |
-
title =
|
90 |
|
91 |
if isinstance(args_manager.args.preset, str):
|
92 |
title += ' ' + args_manager.args.preset
|
@@ -112,7 +112,7 @@ with shared.gradio_root:
|
|
112 |
with gr.Row(elem_classes='type_row'):
|
113 |
with gr.Column(scale=17):
|
114 |
prompt = gr.Textbox(show_label=False, placeholder="Type prompt here or paste parameters.", elem_id='positive_prompt',
|
115 |
-
container=False, autofocus=True, elem_classes='type_row', lines=1024)
|
116 |
|
117 |
default_prompt = modules.config.default_prompt
|
118 |
if isinstance(default_prompt, str) and default_prompt != '':
|
@@ -141,9 +141,9 @@ with shared.gradio_root:
|
|
141 |
stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever')
|
142 |
skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
|
143 |
with gr.Row(elem_classes='advanced_check_row'):
|
144 |
-
input_image_checkbox = gr.Checkbox(label='Input Image', value=
|
145 |
-
advanced_checkbox = gr.Checkbox(label='Advanced', value=
|
146 |
-
with gr.Row(visible=
|
147 |
with gr.Tabs():
|
148 |
with gr.TabItem(label='Upscale or Variation') as uov_tab:
|
149 |
with gr.Row():
|
@@ -151,8 +151,9 @@ with shared.gradio_root:
|
|
151 |
uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy')
|
152 |
with gr.Column():
|
153 |
uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
|
154 |
-
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Document</a>')
|
155 |
with gr.TabItem(label='Image Prompt') as ip_tab:
|
|
|
|
|
156 |
with gr.Row():
|
157 |
ip_images = []
|
158 |
ip_types = []
|
@@ -165,7 +166,7 @@ with shared.gradio_root:
|
|
165 |
ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300)
|
166 |
ip_images.append(ip_image)
|
167 |
ip_ctrls.append(ip_image)
|
168 |
-
with gr.Column(visible=
|
169 |
with gr.Row():
|
170 |
default_end, default_weight = flags.default_parameters[flags.default_ip]
|
171 |
|
@@ -177,14 +178,12 @@ with shared.gradio_root:
|
|
177 |
ip_weights.append(ip_weight)
|
178 |
ip_ctrls.append(ip_weight)
|
179 |
|
180 |
-
ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=
|
181 |
ip_types.append(ip_type)
|
182 |
ip_ctrls.append(ip_type)
|
183 |
|
184 |
ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False)
|
185 |
ip_ad_cols.append(ad_col)
|
186 |
-
ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False)
|
187 |
-
gr.HTML('* \"Image Prompt\" is powered by Fooocus Image Mixture Engine (v1.0.1). <a href="https://github.com/lllyasviel/Fooocus/discussions/557" target="_blank">\U0001F4D4 Document</a>')
|
188 |
|
189 |
def ip_advance_checked(x):
|
190 |
return [gr.update(visible=x)] * len(ip_ad_cols) + \
|
@@ -196,16 +195,19 @@ with shared.gradio_root:
|
|
196 |
outputs=ip_ad_cols + ip_types + ip_stops + ip_weights,
|
197 |
queue=False, show_progress=False)
|
198 |
with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab:
|
|
|
|
|
|
|
|
|
199 |
with gr.Row():
|
200 |
inpaint_input_image = grh.Image(label='Drag inpaint or outpaint image to here', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", elem_id='inpaint_canvas')
|
201 |
inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
|
202 |
|
203 |
with gr.Row():
|
204 |
-
inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False)
|
205 |
outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
|
206 |
inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method')
|
207 |
example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False)
|
208 |
-
gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>')
|
209 |
example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
|
210 |
with gr.TabItem(label='Describe') as desc_tab:
|
211 |
with gr.Row():
|
@@ -217,10 +219,9 @@ with shared.gradio_root:
|
|
217 |
choices=[flags.desc_type_photo, flags.desc_type_anime],
|
218 |
value=flags.desc_type_photo)
|
219 |
desc_btn = gr.Button(value='Describe this Image into Prompt')
|
220 |
-
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Document</a>')
|
221 |
with gr.TabItem(label='Metadata') as load_tab:
|
222 |
with gr.Column():
|
223 |
-
metadata_input_image = grh.Image(label='Drag any image generated
|
224 |
metadata_json = gr.JSON(label='Metadata')
|
225 |
metadata_import_button = gr.Button(value='Apply Metadata')
|
226 |
|
@@ -246,13 +247,13 @@ with shared.gradio_root:
|
|
246 |
outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js)
|
247 |
ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
|
248 |
|
249 |
-
current_tab = gr.Textbox(value='uov', visible=False)
|
250 |
uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
251 |
inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
252 |
ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
253 |
desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
254 |
|
255 |
-
with gr.Column(scale=1, visible=
|
256 |
with gr.Tab(label='Setting'):
|
257 |
performance_selection = gr.Radio(label='Performance',
|
258 |
choices=modules.flags.performance_selections,
|
@@ -269,9 +270,10 @@ with shared.gradio_root:
|
|
269 |
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
|
270 |
info='Describing what you do not want to see.', lines=2,
|
271 |
elem_id='negative_prompt',
|
272 |
-
value=modules.config.default_prompt_negative
|
|
|
273 |
seed_random = gr.Checkbox(label='Random', value=True)
|
274 |
-
image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=
|
275 |
|
276 |
def random_checked(r):
|
277 |
return gr.update(visible=not r)
|
@@ -308,13 +310,14 @@ with shared.gradio_root:
|
|
308 |
style_search_bar = gr.Textbox(show_label=False, container=False,
|
309 |
placeholder="\U0001F50E Type here to search styles ...",
|
310 |
value="",
|
311 |
-
label='Search Styles'
|
|
|
312 |
style_selections = gr.CheckboxGroup(show_label=False, container=False,
|
313 |
choices=copy.deepcopy(style_sorter.all_styles),
|
314 |
value=copy.deepcopy(modules.config.default_styles),
|
315 |
label='Selected Styles',
|
316 |
elem_classes=['style_selections'])
|
317 |
-
gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False)
|
318 |
|
319 |
shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
|
320 |
outputs=style_selections)
|
@@ -374,10 +377,9 @@ with shared.gradio_root:
|
|
374 |
sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
|
375 |
value=modules.config.default_sample_sharpness,
|
376 |
info='Higher value means image and texture are sharper.')
|
377 |
-
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>')
|
378 |
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=True, container=True)
|
379 |
|
380 |
-
with gr.Column(visible=
|
381 |
with gr.Tab(label='Debug Tools'):
|
382 |
adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
383 |
step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
|
@@ -436,11 +438,11 @@ with shared.gradio_root:
|
|
436 |
value=False)
|
437 |
|
438 |
if not args_manager.args.disable_metadata:
|
439 |
-
save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=
|
440 |
info='Adds parameters to generated images allowing manual regeneration.')
|
441 |
metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
|
442 |
info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
|
443 |
-
visible=
|
444 |
|
445 |
save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
|
446 |
queue=False, show_progress=False)
|
@@ -472,7 +474,7 @@ with shared.gradio_root:
|
|
472 |
inpaint_engine = gr.Dropdown(label='Inpaint Engine',
|
473 |
value=modules.config.default_inpaint_engine_version,
|
474 |
choices=flags.inpaint_engine_versions,
|
475 |
-
info='Version of
|
476 |
inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
|
477 |
minimum=0.0, maximum=1.0, step=0.001, value=1.0,
|
478 |
info='Same as the denoising strength in A1111 inpaint. '
|
@@ -490,8 +492,8 @@ with shared.gradio_root:
|
|
490 |
info='Positive value will make white area in the mask larger, '
|
491 |
'negative value will make white area smaller.'
|
492 |
'(default is 0, always process before any mask invert)')
|
493 |
-
inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=True)
|
494 |
-
invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
|
495 |
|
496 |
inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
|
497 |
inpaint_strength, inpaint_respective_field,
|
@@ -667,7 +669,7 @@ with shared.gradio_root:
|
|
667 |
return mode, ["Fooocus V2"]
|
668 |
|
669 |
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
|
670 |
-
outputs=[prompt, style_selections], show_progress=True, queue=
|
671 |
|
672 |
|
673 |
def dump_default_english_config():
|
|
|
86 |
|
87 |
reload_javascript()
|
88 |
|
89 |
+
title = 'AI Image'
|
90 |
|
91 |
if isinstance(args_manager.args.preset, str):
|
92 |
title += ' ' + args_manager.args.preset
|
|
|
112 |
with gr.Row(elem_classes='type_row'):
|
113 |
with gr.Column(scale=17):
|
114 |
prompt = gr.Textbox(show_label=False, placeholder="Type prompt here or paste parameters.", elem_id='positive_prompt',
|
115 |
+
container=False, autofocus=True, elem_classes='type_row', lines=1024, show_copy_button=True)
|
116 |
|
117 |
default_prompt = modules.config.default_prompt
|
118 |
if isinstance(default_prompt, str) and default_prompt != '':
|
|
|
141 |
stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever')
|
142 |
skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
|
143 |
with gr.Row(elem_classes='advanced_check_row'):
|
144 |
+
input_image_checkbox = gr.Checkbox(label='Input Image', value=True, container=True, elem_classes='min_check')
|
145 |
+
advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=True, elem_classes=['min_check', 'advancedSettings'])
|
146 |
+
with gr.Row(visible=True) as image_input_panel:
|
147 |
with gr.Tabs():
|
148 |
with gr.TabItem(label='Upscale or Variation') as uov_tab:
|
149 |
with gr.Row():
|
|
|
151 |
uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy')
|
152 |
with gr.Column():
|
153 |
uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
|
|
|
154 |
with gr.TabItem(label='Image Prompt') as ip_tab:
|
155 |
+
ip_advanced = gr.Checkbox(label='Advanced', value=True, container=True)
|
156 |
+
|
157 |
with gr.Row():
|
158 |
ip_images = []
|
159 |
ip_types = []
|
|
|
166 |
ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300)
|
167 |
ip_images.append(ip_image)
|
168 |
ip_ctrls.append(ip_image)
|
169 |
+
with gr.Column(visible=True) as ad_col:
|
170 |
with gr.Row():
|
171 |
default_end, default_weight = flags.default_parameters[flags.default_ip]
|
172 |
|
|
|
178 |
ip_weights.append(ip_weight)
|
179 |
ip_ctrls.append(ip_weight)
|
180 |
|
181 |
+
ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=True)
|
182 |
ip_types.append(ip_type)
|
183 |
ip_ctrls.append(ip_type)
|
184 |
|
185 |
ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False)
|
186 |
ip_ad_cols.append(ad_col)
|
|
|
|
|
187 |
|
188 |
def ip_advance_checked(x):
|
189 |
return [gr.update(visible=x)] * len(ip_ad_cols) + \
|
|
|
195 |
outputs=ip_ad_cols + ip_types + ip_stops + ip_weights,
|
196 |
queue=False, show_progress=False)
|
197 |
with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab:
|
198 |
+
with gr.Row():
|
199 |
+
inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False)
|
200 |
+
invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
|
201 |
+
|
202 |
with gr.Row():
|
203 |
inpaint_input_image = grh.Image(label='Drag inpaint or outpaint image to here', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", elem_id='inpaint_canvas')
|
204 |
inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
|
205 |
|
206 |
with gr.Row():
|
207 |
+
inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False, show_copy_button=True)
|
208 |
outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
|
209 |
inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method')
|
210 |
example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False)
|
|
|
211 |
example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
|
212 |
with gr.TabItem(label='Describe') as desc_tab:
|
213 |
with gr.Row():
|
|
|
219 |
choices=[flags.desc_type_photo, flags.desc_type_anime],
|
220 |
value=flags.desc_type_photo)
|
221 |
desc_btn = gr.Button(value='Describe this Image into Prompt')
|
|
|
222 |
with gr.TabItem(label='Metadata') as load_tab:
|
223 |
with gr.Column():
|
224 |
+
metadata_input_image = grh.Image(label='Drag any image generated', source='upload', type='filepath')
|
225 |
metadata_json = gr.JSON(label='Metadata')
|
226 |
metadata_import_button = gr.Button(value='Apply Metadata')
|
227 |
|
|
|
247 |
outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js)
|
248 |
ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
|
249 |
|
250 |
+
current_tab = gr.Textbox(value='uov', visible=False, show_copy_button=False)
|
251 |
uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
252 |
inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
253 |
ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
254 |
desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
255 |
|
256 |
+
with gr.Column(scale=1, visible=False) as advanced_column:
|
257 |
with gr.Tab(label='Setting'):
|
258 |
performance_selection = gr.Radio(label='Performance',
|
259 |
choices=modules.flags.performance_selections,
|
|
|
270 |
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
|
271 |
info='Describing what you do not want to see.', lines=2,
|
272 |
elem_id='negative_prompt',
|
273 |
+
value=modules.config.default_prompt_negative,
|
274 |
+
show_copy_button=True)
|
275 |
seed_random = gr.Checkbox(label='Random', value=True)
|
276 |
+
image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=True, show_copy_button=True) # workaround for https://github.com/gradio-app/gradio/issues/5354
|
277 |
|
278 |
def random_checked(r):
|
279 |
return gr.update(visible=not r)
|
|
|
310 |
style_search_bar = gr.Textbox(show_label=False, container=False,
|
311 |
placeholder="\U0001F50E Type here to search styles ...",
|
312 |
value="",
|
313 |
+
label='Search Styles',
|
314 |
+
show_copy_button=True)
|
315 |
style_selections = gr.CheckboxGroup(show_label=False, container=False,
|
316 |
choices=copy.deepcopy(style_sorter.all_styles),
|
317 |
value=copy.deepcopy(modules.config.default_styles),
|
318 |
label='Selected Styles',
|
319 |
elem_classes=['style_selections'])
|
320 |
+
gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False, show_copy_button=True)
|
321 |
|
322 |
shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
|
323 |
outputs=style_selections)
|
|
|
377 |
sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
|
378 |
value=modules.config.default_sample_sharpness,
|
379 |
info='Higher value means image and texture are sharper.')
|
|
|
380 |
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=True, container=True)
|
381 |
|
382 |
+
with gr.Column(visible=True) as dev_tools:
|
383 |
with gr.Tab(label='Debug Tools'):
|
384 |
adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
385 |
step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
|
|
|
438 |
value=False)
|
439 |
|
440 |
if not args_manager.args.disable_metadata:
|
441 |
+
save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=True,
|
442 |
info='Adds parameters to generated images allowing manual regeneration.')
|
443 |
metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
|
444 |
info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
|
445 |
+
visible=True)
|
446 |
|
447 |
save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
|
448 |
queue=False, show_progress=False)
|
|
|
474 |
inpaint_engine = gr.Dropdown(label='Inpaint Engine',
|
475 |
value=modules.config.default_inpaint_engine_version,
|
476 |
choices=flags.inpaint_engine_versions,
|
477 |
+
info='Version of inpaint model')
|
478 |
inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
|
479 |
minimum=0.0, maximum=1.0, step=0.001, value=1.0,
|
480 |
info='Same as the denoising strength in A1111 inpaint. '
|
|
|
492 |
info='Positive value will make white area in the mask larger, '
|
493 |
'negative value will make white area smaller.'
|
494 |
'(default is 0, always process before any mask invert)')
|
495 |
+
# inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=True)
|
496 |
+
# invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
|
497 |
|
498 |
inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
|
499 |
inpaint_strength, inpaint_respective_field,
|
|
|
669 |
return mode, ["Fooocus V2"]
|
670 |
|
671 |
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
|
672 |
+
outputs=[prompt, style_selections], show_progress=True, queue=False)
|
673 |
|
674 |
|
675 |
def dump_default_english_config():
|