refactor: rename image_file_extension to output_format

This commit is contained in:
Manuel Schmid 2024-01-19 00:06:07 +01:00
parent f1261028b8
commit 7e52a1de8f
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
5 changed files with 20 additions and 20 deletions

View File

@ -125,7 +125,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()
@ -513,7 +513,7 @@ def worker():
if direct_return:
d = [('Upscale (Fast)', '2x')]
uov_input_image_path = log(uov_input_image, d, image_file_extension)
uov_input_image_path = log(uov_input_image, d, output_format)
yield_result(async_task, uov_input_image_path, do_not_show_finished_images=True)
return
@ -802,7 +802,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, image_file_extension))
img_paths.append(log(x, d, output_format))
yield_result(async_task, img_paths, do_not_show_finished_images=len(tasks) == 1)
except ldm_patched.modules.model_management.InterruptProcessingException as e:

View File

@ -248,10 +248,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',

View File

@ -34,7 +34,7 @@ default_parameters = {
inpaint_engine_versions = ['None', 'v1', 'v2.5', 'v2.6']
performance_selections = ['Speed', 'Quality', '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.)'

View File

@ -11,21 +11,21 @@ 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, image_extension=None) -> str:
def log(img, dic, output_format=None) -> str:
path_outputs = args_manager.args.temp_path if args_manager.args.disable_image_log else modules.config.path_outputs
_image_extension = image_extension if image_extension else modules.config.default_image_extension
date_string, local_temp_filename, only_name = generate_temp_filename(folder=path_outputs, extension=_image_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_extension == 'jpg':
if output_format == 'jpg':
Image.fromarray(img).save(local_temp_filename, quality=95, optimize=True, progressive=True)
else:
Image.fromarray(img).save(local_temp_filename)

View File

@ -236,9 +236,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,
@ -266,7 +266,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='Style'):
style_sorter.try_load_sorted_styles(
@ -492,7 +492,7 @@ with shared.gradio_root:
scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt
], 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) \
@ -533,7 +533,7 @@ with shared.gradio_root:
ctrls = [
prompt, negative_prompt, 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