Thekingbalxd commited on
Commit
8cd1ef6
1 Parent(s): 775610f

Upload webui (3) (1).py

Browse files
Files changed (1) hide show
  1. webui (3) (1).py +783 -0
webui (3) (1).py ADDED
@@ -0,0 +1,783 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import os
4
+ import json
5
+ import time
6
+ import shared
7
+ import modules.config
8
+ import fooocus_version
9
+ import modules.html
10
+ import modules.async_worker as worker
11
+ import modules.constants as constants
12
+ import modules.flags as flags
13
+ import modules.gradio_hijack as grh
14
+ import modules.style_sorter as style_sorter
15
+ import modules.meta_parser
16
+ import args_manager
17
+ import copy
18
+ import launch
19
+
20
+ from modules.sdxl_styles import legal_style_names
21
+ from modules.private_logger import get_current_html_path
22
+ from modules.ui_gradio_extensions import reload_javascript
23
+ from modules.auth import auth_enabled, check_auth
24
+ from modules.util import is_json
25
+
26
+ def get_task(*args):
27
+ args = list(args)
28
+ args.pop(0)
29
+
30
+ return worker.AsyncTask(args=args)
31
+
32
+ def generate_clicked(task: worker.AsyncTask):
33
+ import ldm_patched.modules.model_management as model_management
34
+
35
+ with model_management.interrupt_processing_mutex:
36
+ model_management.interrupt_processing = False
37
+ # outputs=[progress_html, progress_window, progress_gallery, gallery]
38
+
39
+ if len(task.args) == 0:
40
+ return
41
+
42
+ execution_start_time = time.perf_counter()
43
+ finished = False
44
+
45
+ yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \
46
+ gr.update(visible=True, value=None), \
47
+ gr.update(visible=False, value=None), \
48
+ gr.update(visible=False)
49
+
50
+ worker.async_tasks.append(task)
51
+
52
+ while not finished:
53
+ time.sleep(0.01)
54
+ if len(task.yields) > 0:
55
+ flag, product = task.yields.pop(0)
56
+ if flag == 'preview':
57
+
58
+ # help bad internet connection by skipping duplicated preview
59
+ if len(task.yields) > 0: # if we have the next item
60
+ if task.yields[0][0] == 'preview': # if the next item is also a preview
61
+ # print('Skipped one preview for better internet connection.')
62
+ continue
63
+
64
+ percentage, title, image = product
65
+ yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \
66
+ gr.update(visible=True, value=image) if image is not None else gr.update(), \
67
+ gr.update(), \
68
+ gr.update(visible=False)
69
+ if flag == 'results':
70
+ yield gr.update(visible=True), \
71
+ gr.update(visible=True), \
72
+ gr.update(visible=True, value=product), \
73
+ gr.update(visible=False)
74
+ if flag == 'finish':
75
+ yield gr.update(visible=False), \
76
+ gr.update(visible=False), \
77
+ gr.update(visible=False), \
78
+ gr.update(visible=True, value=product)
79
+ finished = True
80
+
81
+ # delete Fooocus temp images, only keep gradio temp images
82
+ if args_manager.args.disable_image_log:
83
+ for filepath in product:
84
+ if isinstance(filepath, str) and os.path.exists(filepath):
85
+ os.remove(filepath)
86
+
87
+ execution_time = time.perf_counter() - execution_start_time
88
+ print(f'Total time: {execution_time:.2f} seconds')
89
+ return
90
+
91
+
92
+ reload_javascript()
93
+
94
+ title = f'Fooocus {fooocus_version.version}'
95
+
96
+ if isinstance(args_manager.args.preset, str):
97
+ title += ' ' + args_manager.args.preset
98
+
99
+ shared.gradio_root = gr.Blocks(title=title).queue()
100
+
101
+ with shared.gradio_root:
102
+ currentTask = gr.State(worker.AsyncTask(args=[]))
103
+ with gr.Row():
104
+ with gr.Column(scale=2):
105
+ with gr.Row():
106
+ progress_window = grh.Image(label='Preview', show_label=True, visible=False, height=768,
107
+ elem_classes=['main_view'])
108
+ progress_gallery = gr.Gallery(label='Finished Images', show_label=True, object_fit='contain',
109
+ height=768, visible=False, elem_classes=['main_view', 'image_gallery'])
110
+ progress_html = gr.HTML(value=modules.html.make_progress_html(32, 'Progress 32%'), visible=False,
111
+ elem_id='progress-bar', elem_classes='progress-bar')
112
+ gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', visible=True, height=768,
113
+ elem_classes=['resizable_area', 'main_view', 'final_gallery', 'image_gallery'],
114
+ elem_id='final_gallery')
115
+ with gr.Row(elem_classes='type_row'):
116
+ with gr.Column(scale=17):
117
+ prompt = gr.Textbox(show_label=False, placeholder="Type prompt here or paste parameters.", elem_id='positive_prompt',
118
+ container=False, autofocus=True, elem_classes='type_row', lines=1024)
119
+
120
+ default_prompt = modules.config.default_prompt
121
+ if isinstance(default_prompt, str) and default_prompt != '':
122
+ shared.gradio_root.load(lambda: default_prompt, outputs=prompt)
123
+
124
+ with gr.Column(scale=3, min_width=0):
125
+ generate_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', elem_id='generate_button', visible=True)
126
+ reset_button = gr.Button(label="Reconnect", value="Reconnect", elem_classes='type_row', elem_id='reset_button', visible=False)
127
+ load_parameter_button = gr.Button(label="Load Parameters", value="Load Parameters", elem_classes='type_row', elem_id='load_parameter_button', visible=False)
128
+ skip_button = gr.Button(label="Skip", value="Skip", elem_classes='type_row_half', elem_id='skip_button', visible=False)
129
+ stop_button = gr.Button(label="Stop", value="Stop", elem_classes='type_row_half', elem_id='stop_button', visible=False)
130
+
131
+ def stop_clicked(currentTask):
132
+ import ldm_patched.modules.model_management as model_management
133
+ currentTask.last_stop = 'stop'
134
+ if (currentTask.processing):
135
+ model_management.interrupt_current_processing()
136
+ return currentTask
137
+
138
+ def skip_clicked(currentTask):
139
+ import ldm_patched.modules.model_management as model_management
140
+ currentTask.last_stop = 'skip'
141
+ if (currentTask.processing):
142
+ model_management.interrupt_current_processing()
143
+ return currentTask
144
+
145
+ stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever')
146
+ skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
147
+ with gr.Row(elem_classes='advanced_check_row'):
148
+ input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check')
149
+ advanced_checkbox = gr.Checkbox(label='Advanced', value=modules.config.default_advanced_checkbox, container=False, elem_classes='min_check')
150
+ with gr.Row(visible=False) as image_input_panel:
151
+ with gr.Tabs():
152
+ with gr.TabItem(label='Upscale or Variation') as uov_tab:
153
+ with gr.Row():
154
+ with gr.Column():
155
+ uov_input_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False)
156
+ with gr.Column():
157
+ uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
158
+ gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Document</a>')
159
+ with gr.TabItem(label='Image Prompt') as ip_tab:
160
+ with gr.Row():
161
+ ip_images = []
162
+ ip_types = []
163
+ ip_stops = []
164
+ ip_weights = []
165
+ ip_ctrls = []
166
+ ip_ad_cols = []
167
+ for _ in range(flags.controlnet_image_count):
168
+ with gr.Column():
169
+ ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300)
170
+ ip_images.append(ip_image)
171
+ ip_ctrls.append(ip_image)
172
+ with gr.Column(visible=False) as ad_col:
173
+ with gr.Row():
174
+ default_end, default_weight = flags.default_parameters[flags.default_ip]
175
+
176
+ ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=default_end)
177
+ ip_stops.append(ip_stop)
178
+ ip_ctrls.append(ip_stop)
179
+
180
+ ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=default_weight)
181
+ ip_weights.append(ip_weight)
182
+ ip_ctrls.append(ip_weight)
183
+
184
+ ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=False)
185
+ ip_types.append(ip_type)
186
+ ip_ctrls.append(ip_type)
187
+
188
+ ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False)
189
+ ip_ad_cols.append(ad_col)
190
+ ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False)
191
+ 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>')
192
+
193
+ def ip_advance_checked(x):
194
+ return [gr.update(visible=x)] * len(ip_ad_cols) + \
195
+ [flags.default_ip] * len(ip_types) + \
196
+ [flags.default_parameters[flags.default_ip][0]] * len(ip_stops) + \
197
+ [flags.default_parameters[flags.default_ip][1]] * len(ip_weights)
198
+
199
+ ip_advanced.change(ip_advance_checked, inputs=ip_advanced,
200
+ outputs=ip_ad_cols + ip_types + ip_stops + ip_weights,
201
+ queue=False, show_progress=False)
202
+ with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab:
203
+ with gr.Row():
204
+ inpaint_input_image = grh.Image(label='Image', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", elem_id='inpaint_canvas', show_label=False)
205
+ inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
206
+
207
+ with gr.Row():
208
+ inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False)
209
+ outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
210
+ inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method')
211
+ example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False)
212
+ gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>')
213
+ example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
214
+ with gr.TabItem(label='Describe') as desc_tab:
215
+ with gr.Row():
216
+ with gr.Column():
217
+ desc_input_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False)
218
+ with gr.Column():
219
+ desc_method = gr.Radio(
220
+ label='Content Type',
221
+ choices=[flags.desc_type_photo, flags.desc_type_anime],
222
+ value=flags.desc_type_photo)
223
+ desc_btn = gr.Button(value='Describe this Image into Prompt')
224
+ desc_image_size = gr.Textbox(label='Image Size and Recommended Size', elem_id='desc_image_size', visible=False)
225
+ gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Document</a>')
226
+
227
+ def trigger_show_image_properties(image):
228
+ value = modules.util.get_image_size_info(image, modules.flags.sdxl_aspect_ratios)
229
+ return gr.update(value=value, visible=True)
230
+
231
+ desc_input_image.upload(trigger_show_image_properties, inputs=desc_input_image,
232
+ outputs=desc_image_size, show_progress=False, queue=False)
233
+
234
+ with gr.TabItem(label='Metadata') as metadata_tab:
235
+ with gr.Column():
236
+ metadata_input_image = grh.Image(label='For images created by Fooocus', source='upload', type='filepath')
237
+ metadata_json = gr.JSON(label='Metadata')
238
+ metadata_import_button = gr.Button(value='Apply Metadata')
239
+
240
+ def trigger_metadata_preview(filepath):
241
+ parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
242
+
243
+ results = {}
244
+ if parameters is not None:
245
+ results['parameters'] = parameters
246
+
247
+ if isinstance(metadata_scheme, flags.MetadataScheme):
248
+ results['metadata_scheme'] = metadata_scheme.value
249
+
250
+ return results
251
+
252
+ metadata_input_image.upload(trigger_metadata_preview, inputs=metadata_input_image,
253
+ outputs=metadata_json, queue=False, show_progress=True)
254
+
255
+ switch_js = "(x) => {if(x){viewer_to_bottom(100);viewer_to_bottom(500);}else{viewer_to_top();} return x;}"
256
+ down_js = "() => {viewer_to_bottom();}"
257
+
258
+ input_image_checkbox.change(lambda x: gr.update(visible=x), inputs=input_image_checkbox,
259
+ outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js)
260
+ ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
261
+
262
+ current_tab = gr.Textbox(value='uov', visible=False)
263
+ uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
264
+ inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
265
+ ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
266
+ desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
267
+ metadata_tab.select(lambda: 'metadata', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
268
+
269
+ with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column:
270
+ with gr.Tab(label='Setting'):
271
+ if not args_manager.args.disable_preset_selection:
272
+ preset_selection = gr.Dropdown(label='Preset',
273
+ choices=modules.config.available_presets,
274
+ value=args_manager.args.preset if args_manager.args.preset else "initial",
275
+ interactive=True)
276
+ performance_selection = gr.Radio(label='Performance',
277
+ choices=flags.Performance.list(),
278
+ value=modules.config.default_performance,
279
+ elem_classes=['performance_selection'])
280
+ with gr.Accordion(label='Aspect Ratios', open=False, elem_id='aspect_ratios_accordion') as aspect_ratios_accordion:
281
+ aspect_ratios_selection = gr.Radio(label='Aspect Ratios', show_label=False,
282
+ choices=modules.config.available_aspect_ratios_labels,
283
+ value=modules.config.default_aspect_ratio,
284
+ info='width × height',
285
+ elem_classes='aspect_ratios')
286
+
287
+ aspect_ratios_selection.change(lambda x: None, inputs=aspect_ratios_selection, queue=False, show_progress=False, _js='(x)=>{refresh_aspect_ratios_label(x);}')
288
+ shared.gradio_root.load(lambda x: None, inputs=aspect_ratios_selection, queue=False, show_progress=False, _js='(x)=>{refresh_aspect_ratios_label(x);}')
289
+
290
+ image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
291
+
292
+ output_format = gr.Radio(label='Output Format',
293
+ choices=flags.OutputFormat.list(),
294
+ value=modules.config.default_output_format)
295
+
296
+ negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
297
+ info='Describing what you do not want to see.', lines=2,
298
+ elem_id='negative_prompt',
299
+ value=modules.config.default_prompt_negative)
300
+ seed_random = gr.Checkbox(label='Random', value=True)
301
+ image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=False) # workaround for https://github.com/gradio-app/gradio/issues/5354
302
+
303
+ def random_checked(r):
304
+ return gr.update(visible=not r)
305
+
306
+ def refresh_seed(r, seed_string):
307
+ if r:
308
+ return random.randint(constants.MIN_SEED, constants.MAX_SEED)
309
+ else:
310
+ try:
311
+ seed_value = int(seed_string)
312
+ if constants.MIN_SEED <= seed_value <= constants.MAX_SEED:
313
+ return seed_value
314
+ except ValueError:
315
+ pass
316
+ return random.randint(constants.MIN_SEED, constants.MAX_SEED)
317
+
318
+ seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed],
319
+ queue=False, show_progress=False)
320
+
321
+ def update_history_link():
322
+ if args_manager.args.disable_image_log:
323
+ return gr.update(value='')
324
+
325
+ return gr.update(value=f'<a href="file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
326
+
327
+ history_link = gr.HTML()
328
+ shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
329
+
330
+ with gr.Tab(label='Style', elem_classes=['style_selections_tab']):
331
+ style_sorter.try_load_sorted_styles(
332
+ style_names=legal_style_names,
333
+ default_selected=modules.config.default_styles)
334
+
335
+ style_search_bar = gr.Textbox(show_label=False, container=False,
336
+ placeholder="\U0001F50E Type here to search styles ...",
337
+ value="",
338
+ label='Search Styles')
339
+ style_selections = gr.CheckboxGroup(show_label=False, container=False,
340
+ choices=copy.deepcopy(style_sorter.all_styles),
341
+ value=copy.deepcopy(modules.config.default_styles),
342
+ label='Selected Styles',
343
+ elem_classes=['style_selections'])
344
+ gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False)
345
+
346
+ shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
347
+ outputs=style_selections)
348
+
349
+ style_search_bar.change(style_sorter.search_styles,
350
+ inputs=[style_selections, style_search_bar],
351
+ outputs=style_selections,
352
+ queue=False,
353
+ show_progress=False).then(
354
+ lambda: None, _js='()=>{refresh_style_localization();}')
355
+
356
+ gradio_receiver_style_selections.input(style_sorter.sort_styles,
357
+ inputs=style_selections,
358
+ outputs=style_selections,
359
+ queue=False,
360
+ show_progress=False).then(
361
+ lambda: None, _js='()=>{refresh_style_localization();}')
362
+
363
+ with gr.Tab(label='Model'):
364
+ with gr.Group():
365
+ with gr.Row():
366
+ base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True)
367
+ refiner_model = gr.Dropdown(label='Refiner (SDXL or SD 1.5)', choices=['None'] + modules.config.model_filenames, value=modules.config.default_refiner_model_name, show_label=True)
368
+
369
+ refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001,
370
+ info='Use 0.4 for SD1.5 realistic models; '
371
+ 'or 0.667 for SD1.5 anime models; '
372
+ 'or 0.8 for XL-refiners; '
373
+ 'or any value for switching two SDXL models.',
374
+ value=modules.config.default_refiner_switch,
375
+ visible=modules.config.default_refiner_model_name != 'None')
376
+
377
+ refiner_model.change(lambda x: gr.update(visible=x != 'None'),
378
+ inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
379
+
380
+ with gr.Group():
381
+ lora_ctrls = []
382
+
383
+ for i, (enabled, filename, weight) in enumerate(modules.config.default_loras):
384
+ with gr.Row():
385
+ lora_enabled = gr.Checkbox(label='Enable', value=enabled,
386
+ elem_classes=['lora_enable', 'min_check'], scale=1)
387
+ lora_model = gr.Dropdown(label=f'LoRA {i + 1}',
388
+ choices=['None'] + modules.config.lora_filenames, value=filename,
389
+ elem_classes='lora_model', scale=5)
390
+ lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight,
391
+ maximum=modules.config.default_loras_max_weight, step=0.01, value=weight,
392
+ elem_classes='lora_weight', scale=5)
393
+ lora_ctrls += [lora_enabled, lora_model, lora_weight]
394
+
395
+ with gr.Row():
396
+ refresh_files = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
397
+ with gr.Tab(label='Advanced'):
398
+ guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01,
399
+ value=modules.config.default_cfg_scale,
400
+ info='Higher value means style is cleaner, vivider, and more artistic.')
401
+ sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
402
+ value=modules.config.default_sample_sharpness,
403
+ info='Higher value means image and texture are sharper.')
404
+ gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>')
405
+ dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
406
+
407
+ with gr.Column(visible=False) as dev_tools:
408
+ with gr.Tab(label='Debug Tools'):
409
+ adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
410
+ step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
411
+ adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0,
412
+ step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ')
413
+ adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0,
414
+ step=0.001, value=0.3,
415
+ info='When to end the guidance from positive/negative ADM. ')
416
+
417
+ refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method,
418
+ choices=['joint', 'separate', 'vae'])
419
+
420
+ adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01,
421
+ value=modules.config.default_cfg_tsnr,
422
+ info='Enabling Fooocus\'s implementation of CFG mimicking for TSNR '
423
+ '(effective when real CFG > mimicked CFG).')
424
+ clip_skip = gr.Slider(label='CLIP Skip', minimum=1, maximum=10, step=1,
425
+ value=modules.config.default_clip_skip,
426
+ info='Bypass CLIP layers to avoid overfitting (use 1 to disable).')
427
+ sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list,
428
+ value=modules.config.default_sampler)
429
+ scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list,
430
+ value=modules.config.default_scheduler)
431
+ vae_name = gr.Dropdown(label='VAE', choices=[modules.flags.default_vae] + modules.config.vae_filenames,
432
+ value=modules.config.default_vae, show_label=True)
433
+
434
+ generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch',
435
+ info='(Experimental) This may cause performance problems on some computers and certain internet conditions.',
436
+ value=False)
437
+
438
+ overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step',
439
+ minimum=-1, maximum=200, step=1,
440
+ value=modules.config.default_overwrite_step,
441
+ info='Set as -1 to disable. For developer debugging.')
442
+ overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step',
443
+ minimum=-1, maximum=200, step=1,
444
+ value=modules.config.default_overwrite_switch,
445
+ info='Set as -1 to disable. For developer debugging.')
446
+ overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width',
447
+ minimum=-1, maximum=2048, step=1, value=-1,
448
+ info='Set as -1 to disable. For developer debugging. '
449
+ 'Results will be worse for non-standard numbers that SDXL is not trained on.')
450
+ overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height',
451
+ minimum=-1, maximum=2048, step=1, value=-1,
452
+ info='Set as -1 to disable. For developer debugging. '
453
+ 'Results will be worse for non-standard numbers that SDXL is not trained on.')
454
+ overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"',
455
+ minimum=-1, maximum=1.0, step=0.001, value=-1,
456
+ info='Set as negative number to disable. For developer debugging.')
457
+ overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"',
458
+ minimum=-1, maximum=1.0, step=0.001, value=-1,
459
+ info='Set as negative number to disable. For developer debugging.')
460
+ disable_preview = gr.Checkbox(label='Disable Preview', value=modules.config.default_black_out_nsfw,
461
+ interactive=not modules.config.default_black_out_nsfw,
462
+ info='Disable preview during generation.')
463
+ disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results',
464
+ value=modules.config.default_performance == flags.Performance.EXTREME_SPEED.value,
465
+ interactive=modules.config.default_performance != flags.Performance.EXTREME_SPEED.value,
466
+ info='Disable intermediate results during generation, only show final gallery.')
467
+ disable_seed_increment = gr.Checkbox(label='Disable seed increment',
468
+ info='Disable automatic seed increment when image number is > 1.',
469
+ value=False)
470
+ read_wildcards_in_order = gr.Checkbox(label="Read wildcards in order", value=False)
471
+
472
+ black_out_nsfw = gr.Checkbox(label='Black Out NSFW',
473
+ value=modules.config.default_black_out_nsfw,
474
+ interactive=not modules.config.default_black_out_nsfw,
475
+ info='Use black image if NSFW is detected.')
476
+
477
+ black_out_nsfw.change(lambda x: gr.update(value=x, interactive=not x),
478
+ inputs=black_out_nsfw, outputs=disable_preview, queue=False,
479
+ show_progress=False)
480
+
481
+ if not args_manager.args.disable_metadata:
482
+ save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=modules.config.default_save_metadata_to_images,
483
+ info='Adds parameters to generated images allowing manual regeneration.')
484
+ metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
485
+ info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
486
+ visible=modules.config.default_save_metadata_to_images)
487
+
488
+ save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
489
+ queue=False, show_progress=False)
490
+
491
+ with gr.Tab(label='Control'):
492
+ debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False,
493
+ info='See the results from preprocessors.')
494
+ skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=False,
495
+ info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
496
+
497
+ mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale',
498
+ value=False)
499
+ mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint',
500
+ value=False)
501
+
502
+ controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0,
503
+ step=0.001, value=0.25,
504
+ info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
505
+
506
+ with gr.Tab(label='Canny'):
507
+ canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255,
508
+ step=1, value=64)
509
+ canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255,
510
+ step=1, value=128)
511
+
512
+ with gr.Tab(label='Inpaint'):
513
+ debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False)
514
+ inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False)
515
+ inpaint_engine = gr.Dropdown(label='Inpaint Engine',
516
+ value=modules.config.default_inpaint_engine_version,
517
+ choices=flags.inpaint_engine_versions,
518
+ info='Version of Fooocus inpaint model')
519
+ inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
520
+ minimum=0.0, maximum=1.0, step=0.001, value=1.0,
521
+ info='Same as the denoising strength in A1111 inpaint. '
522
+ 'Only used in inpaint, not used in outpaint. '
523
+ '(Outpaint always use 1.0)')
524
+ inpaint_respective_field = gr.Slider(label='Inpaint Respective Field',
525
+ minimum=0.0, maximum=1.0, step=0.001, value=0.618,
526
+ info='The area to inpaint. '
527
+ 'Value 0 is same as "Only Masked" in A1111. '
528
+ 'Value 1 is same as "Whole Image" in A1111. '
529
+ 'Only used in inpaint, not used in outpaint. '
530
+ '(Outpaint always use 1.0)')
531
+ inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate',
532
+ minimum=-64, maximum=64, step=1, value=0,
533
+ info='Positive value will make white area in the mask larger, '
534
+ 'negative value will make white area smaller.'
535
+ '(default is 0, always process before any mask invert)')
536
+ inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False)
537
+ invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
538
+
539
+ inpaint_mask_color = gr.ColorPicker(label='Inpaint brush color', value='#FFFFFF', elem_id='inpaint_brush_color')
540
+
541
+ inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
542
+ inpaint_strength, inpaint_respective_field,
543
+ inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
544
+
545
+ inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x),
546
+ inputs=inpaint_mask_upload_checkbox,
547
+ outputs=inpaint_mask_image, queue=False,
548
+ show_progress=False)
549
+
550
+ inpaint_mask_color.change(lambda x: gr.update(brush_color=x), inputs=inpaint_mask_color,
551
+ outputs=inpaint_input_image,
552
+ queue=False, show_progress=False)
553
+
554
+ with gr.Tab(label='FreeU'):
555
+ freeu_enabled = gr.Checkbox(label='Enabled', value=False)
556
+ freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01)
557
+ freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02)
558
+ freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99)
559
+ freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95)
560
+ freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
561
+
562
+ def dev_mode_checked(r):
563
+ return gr.update(visible=r)
564
+
565
+ dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools],
566
+ queue=False, show_progress=False)
567
+
568
+ def refresh_files_clicked():
569
+ modules.config.update_files()
570
+ results = [gr.update(choices=modules.config.model_filenames)]
571
+ results += [gr.update(choices=['None'] + modules.config.model_filenames)]
572
+ results += [gr.update(choices=['None'] + modules.config.vae_filenames)]
573
+ if not args_manager.args.disable_preset_selection:
574
+ results += [gr.update(choices=modules.config.available_presets)]
575
+ for i in range(modules.config.default_max_lora_number):
576
+ results += [gr.update(interactive=True),
577
+ gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()]
578
+ return results
579
+
580
+ refresh_files_output = [base_model, refiner_model, vae_name]
581
+ if not args_manager.args.disable_preset_selection:
582
+ refresh_files_output += [preset_selection]
583
+ refresh_files.click(refresh_files_clicked, [], refresh_files_output + lora_ctrls,
584
+ queue=False, show_progress=False)
585
+
586
+ state_is_generating = gr.State(False)
587
+
588
+ load_data_outputs = [advanced_checkbox, image_number, prompt, negative_prompt, style_selections,
589
+ performance_selection, overwrite_step, overwrite_switch, aspect_ratios_selection,
590
+ overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive,
591
+ adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, clip_skip,
592
+ base_model, refiner_model, refiner_switch, sampler_name, scheduler_name, vae_name,
593
+ seed_random, image_seed, generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
594
+
595
+ if not args_manager.args.disable_preset_selection:
596
+ def preset_selection_change(preset, is_generating):
597
+ preset_content = modules.config.try_get_preset_content(preset) if preset != 'initial' else {}
598
+ preset_prepared = modules.meta_parser.parse_meta_from_preset(preset_content)
599
+
600
+ default_model = preset_prepared.get('base_model')
601
+ previous_default_models = preset_prepared.get('previous_default_models', [])
602
+ checkpoint_downloads = preset_prepared.get('checkpoint_downloads', {})
603
+ embeddings_downloads = preset_prepared.get('embeddings_downloads', {})
604
+ lora_downloads = preset_prepared.get('lora_downloads', {})
605
+
606
+ preset_prepared['base_model'], preset_prepared['lora_downloads'] = launch.download_models(
607
+ default_model, previous_default_models, checkpoint_downloads, embeddings_downloads, lora_downloads)
608
+
609
+ if 'prompt' in preset_prepared and preset_prepared.get('prompt') == '':
610
+ del preset_prepared['prompt']
611
+
612
+ return modules.meta_parser.load_parameter_button_click(json.dumps(preset_prepared), is_generating)
613
+
614
+ preset_selection.change(preset_selection_change, inputs=[preset_selection, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \
615
+ .then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
616
+
617
+ performance_selection.change(lambda x: [gr.update(interactive=not flags.Performance.has_restricted_features(x))] * 11 +
618
+ [gr.update(visible=not flags.Performance.has_restricted_features(x))] * 1 +
619
+ [gr.update(interactive=not flags.Performance.has_restricted_features(x), value=flags.Performance.has_restricted_features(x))] * 1,
620
+ inputs=performance_selection,
621
+ outputs=[
622
+ guidance_scale, sharpness, adm_scaler_end, adm_scaler_positive,
623
+ adm_scaler_negative, refiner_switch, refiner_model, sampler_name,
624
+ scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results
625
+ ], queue=False, show_progress=False)
626
+
627
+ output_format.input(lambda x: gr.update(output_format=x), inputs=output_format)
628
+
629
+ advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column,
630
+ queue=False, show_progress=False) \
631
+ .then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
632
+
633
+ def inpaint_mode_change(mode):
634
+ assert mode in modules.flags.inpaint_options
635
+
636
+ # inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
637
+ # inpaint_disable_initial_latent, inpaint_engine,
638
+ # inpaint_strength, inpaint_respective_field
639
+
640
+ if mode == modules.flags.inpaint_option_detail:
641
+ return [
642
+ gr.update(visible=True), gr.update(visible=False, value=[]),
643
+ gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts),
644
+ False, 'None', 0.5, 0.0
645
+ ]
646
+
647
+ if mode == modules.flags.inpaint_option_modify:
648
+ return [
649
+ gr.update(visible=True), gr.update(visible=False, value=[]),
650
+ gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
651
+ True, modules.config.default_inpaint_engine_version, 1.0, 0.0
652
+ ]
653
+
654
+ return [
655
+ gr.update(visible=False, value=''), gr.update(visible=True),
656
+ gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
657
+ False, modules.config.default_inpaint_engine_version, 1.0, 0.618
658
+ ]
659
+
660
+ inpaint_mode.input(inpaint_mode_change, inputs=inpaint_mode, outputs=[
661
+ inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
662
+ inpaint_disable_initial_latent, inpaint_engine,
663
+ inpaint_strength, inpaint_respective_field
664
+ ], show_progress=False, queue=False)
665
+
666
+ ctrls = [currentTask, generate_image_grid]
667
+ ctrls += [
668
+ prompt, negative_prompt, style_selections,
669
+ performance_selection, aspect_ratios_selection, image_number, output_format, image_seed,
670
+ read_wildcards_in_order, sharpness, guidance_scale
671
+ ]
672
+
673
+ ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls
674
+ ctrls += [input_image_checkbox, current_tab]
675
+ ctrls += [uov_method, uov_input_image]
676
+ ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt, inpaint_mask_image]
677
+ ctrls += [disable_preview, disable_intermediate_results, disable_seed_increment, black_out_nsfw]
678
+ ctrls += [adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg, clip_skip]
679
+ ctrls += [sampler_name, scheduler_name, vae_name]
680
+ ctrls += [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength]
681
+ ctrls += [overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint]
682
+ ctrls += [debugging_cn_preprocessor, skipping_cn_preprocessor, canny_low_threshold, canny_high_threshold]
683
+ ctrls += [refiner_swap_method, controlnet_softness]
684
+ ctrls += freeu_ctrls
685
+ ctrls += inpaint_ctrls
686
+
687
+ if not args_manager.args.disable_metadata:
688
+ ctrls += [save_metadata_to_images, metadata_scheme]
689
+
690
+ ctrls += ip_ctrls
691
+
692
+ def parse_meta(raw_prompt_txt, is_generating):
693
+ loaded_json = None
694
+ if is_json(raw_prompt_txt):
695
+ loaded_json = json.loads(raw_prompt_txt)
696
+
697
+ if loaded_json is None:
698
+ if is_generating:
699
+ return gr.update(), gr.update(), gr.update()
700
+ else:
701
+ return gr.update(), gr.update(visible=True), gr.update(visible=False)
702
+
703
+ return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True)
704
+
705
+ prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False)
706
+
707
+ load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=[prompt, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=False)
708
+
709
+ def trigger_metadata_import(filepath, state_is_generating):
710
+ parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
711
+ if parameters is None:
712
+ print('Could not find metadata in the image!')
713
+ parsed_parameters = {}
714
+ else:
715
+ metadata_parser = modules.meta_parser.get_metadata_parser(metadata_scheme)
716
+ parsed_parameters = metadata_parser.parse_json(parameters)
717
+
718
+ return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating)
719
+
720
+ metadata_import_button.click(trigger_metadata_import, inputs=[metadata_input_image, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \
721
+ .then(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
722
+
723
+ generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), [], True),
724
+ outputs=[stop_button, skip_button, generate_button, gallery, state_is_generating]) \
725
+ .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \
726
+ .then(fn=get_task, inputs=ctrls, outputs=currentTask) \
727
+ .then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \
728
+ .then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), gr.update(visible=False, interactive=False), False),
729
+ outputs=[generate_button, stop_button, skip_button, state_is_generating]) \
730
+ .then(fn=update_history_link, outputs=history_link) \
731
+ .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')
732
+
733
+ reset_button.click(lambda: [worker.AsyncTask(args=[]), False, gr.update(visible=True, interactive=True)] +
734
+ [gr.update(visible=False)] * 6 +
735
+ [gr.update(visible=True, value=[])],
736
+ outputs=[currentTask, state_is_generating, generate_button,
737
+ reset_button, stop_button, skip_button,
738
+ progress_html, progress_window, progress_gallery, gallery],
739
+ queue=False)
740
+
741
+ for notification_file in ['notification.ogg', 'notification.mp3']:
742
+ if os.path.exists(notification_file):
743
+ gr.Audio(interactive=False, value=notification_file, elem_id='audio_notification', visible=False)
744
+ break
745
+
746
+ def trigger_describe(mode, img):
747
+ if mode == flags.desc_type_photo:
748
+ from extras.interrogate import default_interrogator as default_interrogator_photo
749
+ return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"]
750
+ if mode == flags.desc_type_anime:
751
+ from extras.wd14tagger import default_interrogator as default_interrogator_anime
752
+ return default_interrogator_anime(img), ["Fooocus V2", "Fooocus Masterpiece"]
753
+ return mode, ["Fooocus V2"]
754
+
755
+ desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
756
+ outputs=[prompt, style_selections], show_progress=True, queue=True)
757
+
758
+ if args_manager.args.enable_describe_uov_image:
759
+ def trigger_uov_describe(mode, img, prompt):
760
+ # keep prompt if not empty
761
+ if prompt == '':
762
+ return trigger_describe(mode, img)
763
+ return gr.update(), gr.update()
764
+
765
+ uov_input_image.upload(trigger_uov_describe, inputs=[desc_method, uov_input_image, prompt],
766
+ outputs=[prompt, style_selections], show_progress=True, queue=True)
767
+
768
+ def dump_default_english_config():
769
+ from modules.localization import dump_english_config
770
+ dump_english_config(grh.all_components)
771
+
772
+
773
+ # dump_default_english_config()
774
+
775
+ shared.gradio_root.launch(
776
+ inbrowser=args_manager.args.in_browser,
777
+ server_name=args_manager.args.listen,
778
+ server_port=args_manager.args.port,
779
+ share=args_manager.args.share,
780
+ auth=check_auth if (args_manager.args.share or args_manager.args.listen) and auth_enabled else None,
781
+ allowed_paths=[modules.config.path_outputs],
782
+ blocked_paths=[constants.AUTH_FILENAME]
783
+ )