mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
feat: sort enhance images (mashb1t#62)
* feat: add checkbox, config and handling for saving only the final enhanced image
* feat: sort output of enhance feature
(cherry picked from commit 9d45c0e6ca)
This commit is contained in:
@@ -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), \
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user