Merge branch 'jpg_config_image_extension'
# Conflicts: # modules/async_worker.py # modules/flags.py # modules/private_logger.py # webui.py
This commit is contained in:
commit
72d1e48def
|
|
@ -138,7 +138,7 @@ def worker():
|
|||
performance_selection = args.pop()
|
||||
aspect_ratios_selection = args.pop()
|
||||
image_number = args.pop()
|
||||
image_file_extension = args.pop()
|
||||
output_format = args.pop()
|
||||
image_seed = args.pop()
|
||||
sharpness = args.pop()
|
||||
guidance_scale = args.pop()
|
||||
|
|
@ -547,7 +547,7 @@ def worker():
|
|||
|
||||
if direct_return:
|
||||
d = [('Upscale (Fast)', '2x')]
|
||||
uov_input_image_path = log(uov_input_image, d, image_file_extension=image_file_extension)
|
||||
uov_input_image_path = log(uov_input_image, d, output_format=output_format)
|
||||
yield_result(async_task, uov_input_image_path, do_not_show_finished_images=True)
|
||||
return
|
||||
|
||||
|
|
@ -932,7 +932,7 @@ def worker():
|
|||
if n != 'None':
|
||||
d.append((f'LoRA {li + 1}', f'{n} : {w}'))
|
||||
d.append(('Version', 'v' + fooocus_version.version))
|
||||
img_paths.append(log(x, d, metadata_string, save_metadata_to_images, image_file_extension))
|
||||
img_paths.append(log(x, d, metadata_string, save_metadata_to_images, output_format))
|
||||
|
||||
yield_result(async_task, img_paths, do_not_show_finished_images=len(tasks) == 1, progressbar_index=int(15.0 + 85.0 * float((current_task_id + 1) * steps) / float(all_steps)))
|
||||
except ldm_patched.modules.model_management.InterruptProcessingException as e:
|
||||
|
|
|
|||
|
|
@ -289,10 +289,10 @@ default_max_image_number = get_config_item_or_set_default(
|
|||
default_value=32,
|
||||
validator=lambda x: isinstance(x, int) and x >= 1
|
||||
)
|
||||
default_image_file_extension = get_config_item_or_set_default(
|
||||
key='default_image_file_extension',
|
||||
default_output_format = get_config_item_or_set_default(
|
||||
key='default_output_format',
|
||||
default_value='png',
|
||||
validator=lambda x: x in modules.flags.image_file_extensions
|
||||
validator=lambda x: x in modules.flags.output_formats
|
||||
)
|
||||
default_image_number = get_config_item_or_set_default(
|
||||
key='default_image_number',
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ performance_selections = [
|
|||
('Extreme Speed (LCM) <span style="color: grey;"> \U00002223 8 steps, intermediate results disabled</span>', 'Extreme Speed')
|
||||
]
|
||||
|
||||
image_file_extensions = ['png', 'jpg', 'webp']
|
||||
output_formats = ['png', 'jpg', 'webp']
|
||||
|
||||
inpaint_option_default = 'Inpaint or Outpaint (default)'
|
||||
inpaint_option_detail = 'Improve Detail (face, hand, eyes, etc.)'
|
||||
|
|
|
|||
|
|
@ -12,31 +12,31 @@ from tempfile import gettempdir
|
|||
log_cache = {}
|
||||
|
||||
|
||||
def get_current_html_path(image_extension=None):
|
||||
_image_extension = image_extension if image_extension else modules.config.default_image_extension
|
||||
def get_current_html_path(output_format=None):
|
||||
output_format = output_format if output_format else modules.config.default_output_format
|
||||
date_string, local_temp_filename, only_name = generate_temp_filename(folder=modules.config.path_outputs,
|
||||
extension=_image_extension)
|
||||
extension=output_format)
|
||||
html_name = os.path.join(os.path.dirname(local_temp_filename), 'log.html')
|
||||
return html_name
|
||||
|
||||
|
||||
def log(img, dic, metadata=None, save_metadata_to_image=False, image_file_extension=None) -> str:
|
||||
def log(img, dic, metadata=None, save_metadata_to_image=False, output_format=None) -> str:
|
||||
path_outputs = args_manager.args.temp_path if args_manager.args.disable_image_log else modules.config.path_outputs
|
||||
image_file_extension = image_file_extension if image_file_extension else modules.config.default_image_file_extension
|
||||
date_string, local_temp_filename, only_name = generate_temp_filename(folder=path_outputs, extension=image_file_extension)
|
||||
output_format = output_format if output_format else modules.config.default_output_format
|
||||
date_string, local_temp_filename, only_name = generate_temp_filename(folder=path_outputs, extension=output_format)
|
||||
os.makedirs(os.path.dirname(local_temp_filename), exist_ok=True)
|
||||
|
||||
if image_file_extension == 'png':
|
||||
if output_format == 'png':
|
||||
if save_metadata_to_image:
|
||||
pnginfo = PngInfo()
|
||||
pnginfo.add_text("parameters", metadata)
|
||||
else:
|
||||
pnginfo = None
|
||||
Image.fromarray(img).save(local_temp_filename, pnginfo=pnginfo)
|
||||
elif image_file_extension == 'jpg':
|
||||
elif output_format == 'jpg':
|
||||
# TODO check if metadata works correctly here
|
||||
Image.fromarray(img).save(local_temp_filename, quality=95, optimize=True, progressive=True, comment=metadata if save_metadata_to_image else None)
|
||||
elif image_file_extension == 'webp':
|
||||
elif output_format == 'webp':
|
||||
# TODO test exif handling
|
||||
Image.fromarray(img).save(local_temp_filename, quality=95, lossless=False)
|
||||
else:
|
||||
|
|
|
|||
12
webui.py
12
webui.py
|
|
@ -249,9 +249,9 @@ with shared.gradio_root:
|
|||
elem_classes='aspect_ratios')
|
||||
image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
|
||||
|
||||
image_file_extension = gr.Radio(label='Image File Extension',
|
||||
choices=modules.flags.image_file_extensions,
|
||||
value=modules.config.default_image_file_extension)
|
||||
output_format = gr.Radio(label='Output Format',
|
||||
choices=modules.flags.output_formats,
|
||||
value=modules.config.default_output_format)
|
||||
|
||||
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
|
||||
info='Describing what you do not want to see.', lines=2,
|
||||
|
|
@ -282,7 +282,7 @@ with shared.gradio_root:
|
|||
queue=False, show_progress=False)
|
||||
|
||||
if not args_manager.args.disable_image_log:
|
||||
gr.HTML(f'<a href="/file={get_current_html_path(image_file_extension)}" target="_blank">\U0001F4DA History Log</a>')
|
||||
gr.HTML(f'<a href="/file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
|
||||
|
||||
with gr.Tab(label='Styles'):
|
||||
style_sorter.try_load_sorted_styles(
|
||||
|
|
@ -603,7 +603,7 @@ with shared.gradio_root:
|
|||
scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results
|
||||
], queue=False, show_progress=False)
|
||||
|
||||
image_file_extension.input(lambda x: gr.update(image_file_extension=x), inputs=image_file_extension)
|
||||
output_format.input(lambda x: gr.update(output_format=x), inputs=output_format)
|
||||
|
||||
advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column,
|
||||
queue=False, show_progress=False) \
|
||||
|
|
@ -644,7 +644,7 @@ with shared.gradio_root:
|
|||
|
||||
ctrls = [
|
||||
currentTask, prompt, negative_prompt, translate_prompts, style_selections,
|
||||
performance_selection, aspect_ratios_selection, image_number, image_file_extension, image_seed, sharpness, guidance_scale
|
||||
performance_selection, aspect_ratios_selection, image_number, output_format, image_seed, sharpness, guidance_scale
|
||||
]
|
||||
|
||||
ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls
|
||||
|
|
|
|||
Loading…
Reference in New Issue