Skip to content

Commit

Permalink
Merge pull request #3359 from lllyasviel/develop
Browse files Browse the repository at this point in the history
Release v2.5.1
  • Loading branch information
mashb1t committed Jul 25, 2024
2 parents 3a20e14 + 03655fa commit c4ce2ce
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 29 deletions.
5 changes: 4 additions & 1 deletion args_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

args_parser.parser.add_argument("--theme", type=str, help="launches the UI with light or dark theme", default=None)
args_parser.parser.add_argument("--disable-image-log", action='store_true',
help="Prevent writing images and logs to hard drive.")
help="Prevent writing images and logs to the outputs folder.")

args_parser.parser.add_argument("--disable-analytics", action='store_true',
help="Disables analytics for Gradio.")
Expand All @@ -28,6 +28,9 @@
args_parser.parser.add_argument("--disable-preset-download", action='store_true',
help="Disables downloading models for presets", default=False)

args_parser.parser.add_argument("--disable-enhance-output-sorting", action='store_true',
help="Disables enhance output sorting for final image gallery.")

args_parser.parser.add_argument("--enable-auto-describe-image", action='store_true',
help="Enables automatic description of uov and enhance image when prompt is empty", default=False)

Expand Down
2 changes: 1 addition & 1 deletion fooocus_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '2.5.0'
version = '2.5.1'
3 changes: 3 additions & 0 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
"Read wildcards in order": "Read wildcards in order",
"Black Out NSFW": "Black Out NSFW",
"Use black image if NSFW is detected.": "Use black image if NSFW is detected.",
"Save only final enhanced image": "Save only final enhanced image",
"Save Metadata to Images": "Save Metadata to Images",
"Adds parameters to generated images allowing manual regeneration.": "Adds parameters to generated images allowing manual regeneration.",
"\ud83d\udcda History Log": "\uD83D\uDCDA History Log",
"Image Style": "Image Style",
"Fooocus V2": "Fooocus V2",
Expand Down
72 changes: 47 additions & 25 deletions modules/async_worker.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@ def init_temp_path(path: str | None, default_path: str) -> str:
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_save_only_final_enhanced_image = get_config_item_or_set_default(
key='default_save_only_final_enhanced_image',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_save_metadata_to_images = get_config_item_or_set_default(
key='default_save_metadata_to_images',
default_value=False,
Expand Down
4 changes: 2 additions & 2 deletions modules/private_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def get_current_html_path(output_format=None):
return html_name


def log(img, metadata, metadata_parser: MetadataParser | None = None, output_format=None, task=None) -> str:
path_outputs = modules.config.temp_path if args_manager.args.disable_image_log else modules.config.path_outputs
def log(img, metadata, metadata_parser: MetadataParser | None = None, output_format=None, task=None, persist_image=True) -> str:
path_outputs = modules.config.temp_path if args_manager.args.disable_image_log or not persist_image else modules.config.path_outputs
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)
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ entry_with_update.py [-h] [--listen [IP]] [--port PORT]
[--disable-offload-from-vram] [--theme THEME]
[--disable-image-log] [--disable-analytics]
[--disable-metadata] [--disable-preset-download]
[--disable-enhance-output-sorting]
[--enable-auto-describe-image]
[--always-download-new-model]
[--rebuild-hash-cache [CPU_NUM_THREADS]]
Expand Down
10 changes: 10 additions & 0 deletions update_log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# [2.5.1](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.1)

* Update download URL in readme
* Increase speed of metadata loading
* Fix reading of metadata from jpeg, jpg and webp (exif)
* Fix debug preprocessor
* Update attributes and add inline prompt features section to readme
* Add checkbox, config and handling for saving only the final enhanced image. Use config `default_save_only_final_enhanced_image`, default False.
* Add sorting of final images when enhanced is enabled. Use argument `--disable-enhance-output-sorting` to disable.

# [2.5.0](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.0)

This version includes various package updates. If the auto-update doesn't work you can do one of the following:
Expand Down
29 changes: 29 additions & 0 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def generate_clicked(task: worker.AsyncTask):
gr.update(visible=True, value=product), \
gr.update(visible=False)
if flag == 'finish':
if not args_manager.args.disable_enhance_output_sorting:
product = sort_enhance_images(product, task)

yield gr.update(visible=False), \
gr.update(visible=False), \
gr.update(visible=False), \
Expand All @@ -90,6 +93,25 @@ def generate_clicked(task: worker.AsyncTask):
return


def sort_enhance_images(images, task):
if not task.should_enhance or len(images) <= task.images_to_enhance_count:
return images

sorted_images = []
walk_index = task.images_to_enhance_count

for index, enhanced_img in enumerate(images[:task.images_to_enhance_count]):
sorted_images.append(enhanced_img)
if index not in task.enhance_stats:
continue
target_index = walk_index + task.enhance_stats[index]
if walk_index < len(images) and target_index <= len(images):
sorted_images += images[walk_index:target_index]
walk_index += task.enhance_stats[index]

return sorted_images


def inpaint_mode_change(mode, inpaint_engine_version):
assert mode in modules.flags.inpaint_options

Expand Down Expand Up @@ -748,6 +770,10 @@ def update_history_link():
inputs=black_out_nsfw, outputs=disable_preview, queue=False,
show_progress=False)

if not args_manager.args.disable_image_log:
save_final_enhanced_image_only = gr.Checkbox(label='Save only final enhanced image',
value=modules.config.default_save_only_final_enhanced_image)

if not args_manager.args.disable_metadata:
save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=modules.config.default_save_metadata_to_images,
info='Adds parameters to generated images allowing manual regeneration.')
Expand Down Expand Up @@ -969,6 +995,9 @@ def inpaint_engine_state_change(inpaint_engine_version, *args):
ctrls += freeu_ctrls
ctrls += inpaint_ctrls

if not args_manager.args.disable_image_log:
ctrls += [save_final_enhanced_image_only]

if not args_manager.args.disable_metadata:
ctrls += [save_metadata_to_images, metadata_scheme]

Expand Down

0 comments on commit c4ce2ce

Please sign in to comment.