UPDATE: Save Original On/Off w/Multiple Source

Feature Request #250

+VersionUP (0.6.0 alpha2)
This commit is contained in:
Gourieff 2023-12-09 21:27:08 +07:00
parent fda111bb3d
commit 3b50def406
5 changed files with 21 additions and 15 deletions

View File

@ -2,7 +2,7 @@
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_EN.png?raw=true" alt="logo" width="180px"/> <img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_EN.png?raw=true" alt="logo" width="180px"/>
![Version](https://img.shields.io/badge/version-0.6.0_alpha1-lightgreen?style=for-the-badge&labelColor=darkgreen) ![Version](https://img.shields.io/badge/version-0.6.0_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen)
<a href="https://boosty.to/artgourieff" target="_blank"> <a href="https://boosty.to/artgourieff" target="_blank">
<img src="https://lovemet.ru/www/boosty.jpg" width="108" alt="Support Me on Boosty"/> <img src="https://lovemet.ru/www/boosty.jpg" width="108" alt="Support Me on Boosty"/>

View File

@ -2,7 +2,7 @@
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_RU.png?raw=true" alt="logo" width="180px"/> <img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_RU.png?raw=true" alt="logo" width="180px"/>
![Version](https://img.shields.io/badge/версия-0.6.0_alpha1-lightgreen?style=for-the-badge&labelColor=darkgreen) ![Version](https://img.shields.io/badge/версия-0.6.0_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen)
<a href="https://boosty.to/artgourieff" target="_blank"> <a href="https://boosty.to/artgourieff" target="_blank">
<img src="https://lovemet.ru/www/boosty.jpg" width="108" alt="Поддержать проект на Boosty"/> <img src="https://lovemet.ru/www/boosty.jpg" width="108" alt="Поддержать проект на Boosty"/>
@ -46,6 +46,8 @@
<img src="https://github.com/Gourieff/Assets/blob/main/sd-webui-reactor/multiple_source_images_demo_01.png?raw=true" alt="0.6.0-whatsnew-01" width="100%"/> <img src="https://github.com/Gourieff/Assets/blob/main/sd-webui-reactor/multiple_source_images_demo_01.png?raw=true" alt="0.6.0-whatsnew-01" width="100%"/>
<img src="https://github.com/Gourieff/Assets/blob/main/sd-webui-reactor/multiple_source_images_demo_02.png?raw=true" alt="0.6.0-whatsnew-02" width="100%"/>
### 0.5.1 ### 0.5.1
- Теперь можно сохранять модели лиц в качестве файлов "safetensors" (находятся в `<sd-web-ui-folder>\models\reactor\faces`) и загружать их с ReActor, храня супер легкие модели лиц, которые вы чаще всего используете; - Теперь можно сохранять модели лиц в качестве файлов "safetensors" (находятся в `<sd-web-ui-folder>\models\reactor\faces`) и загружать их с ReActor, храня супер легкие модели лиц, которые вы чаще всего используете;

View File

@ -8,7 +8,7 @@ from scripts.reactor_swapper import (
) )
from modules import shared from modules import shared
SAVE_ORIGINAL: bool = False # SAVE_ORIGINAL: bool = False
def update_fm_list(selected: str): def update_fm_list(selected: str):
return gr.Dropdown.update( return gr.Dropdown.update(
@ -18,16 +18,17 @@ def update_fm_list(selected: str):
# TAB MAIN # TAB MAIN
def show(is_img2img: bool, show_br: bool = True, **msgs): def show(is_img2img: bool, show_br: bool = True, **msgs):
def on_select_source(selected: bool, evt: gr.SelectData): # def on_select_source(selected: bool, evt: gr.SelectData):
global SAVE_ORIGINAL def on_select_source(evt: gr.SelectData):
# global SAVE_ORIGINAL
if evt.index == 2: if evt.index == 2:
if SAVE_ORIGINAL != selected: # if SAVE_ORIGINAL != selected:
SAVE_ORIGINAL = selected # SAVE_ORIGINAL = selected
return { return {
control_col_1: gr.Column.update(visible=False), control_col_1: gr.Column.update(visible=False),
control_col_2: gr.Column.update(visible=False), control_col_2: gr.Column.update(visible=False),
control_col_3: gr.Column.update(visible=True), control_col_3: gr.Column.update(visible=True),
save_original: gr.Checkbox.update(value=False,visible=False), # save_original: gr.Checkbox.update(value=False,visible=False),
imgs_hash_clear: gr.Button.update(visible=True) imgs_hash_clear: gr.Button.update(visible=True)
} }
if evt.index == 0: if evt.index == 0:
@ -35,7 +36,7 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
control_col_1: gr.Column.update(visible=True), control_col_1: gr.Column.update(visible=True),
control_col_2: gr.Column.update(visible=False), control_col_2: gr.Column.update(visible=False),
control_col_3: gr.Column.update(visible=False), control_col_3: gr.Column.update(visible=False),
save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br), # save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button.update(visible=False) imgs_hash_clear: gr.Button.update(visible=False)
} }
if evt.index == 1: if evt.index == 1:
@ -43,7 +44,7 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
control_col_1: gr.Column.update(visible=False), control_col_1: gr.Column.update(visible=False),
control_col_2: gr.Column.update(visible=True), control_col_2: gr.Column.update(visible=True),
control_col_3: gr.Column.update(visible=False), control_col_3: gr.Column.update(visible=False),
save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br), # save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button.update(visible=False) imgs_hash_clear: gr.Button.update(visible=False)
} }
@ -106,13 +107,13 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
save_original = gr.Checkbox( save_original = gr.Checkbox(
False, False,
label="Save Original (Swap in generated only)", label="Save Original (Swap in generated only)",
info="Save the original image(s) made before swapping (it always saves Original when you use Multiple Images or Folder)" info="Save the original image(s) made before swapping"
) )
else: else:
save_original = gr.Checkbox( save_original = gr.Checkbox(
False, False,
label="Save Original", label="Save Original",
info="Save the original image(s) made before swapping (it always saves Original when you use Multiple Images or Folder)", info="Save the original image(s) made before swapping",
visible=show_br visible=show_br
) )
# imgs.upload(on_files_upload_uncheck_so,[save_original],[save_original],show_progress=False) # imgs.upload(on_files_upload_uncheck_so,[save_original],[save_original],show_progress=False)
@ -177,6 +178,6 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
label="Swap in generated image", label="Swap in generated image",
visible=is_img2img, visible=is_img2img,
) )
select_source.select(on_select_source,[save_original],[control_col_1,control_col_2,control_col_3,save_original,imgs_hash_clear],show_progress=False) select_source.select(on_select_source,None,[control_col_1,control_col_2,control_col_3,imgs_hash_clear],show_progress=False)
return img, imgs, select_source, face_model, source_folder, save_original, mask_face, source_faces_index, gender_source, faces_index, gender_target, face_restorer_name, face_restorer_visibility, codeformer_weight, swap_in_source, swap_in_generated return img, imgs, select_source, face_model, source_folder, save_original, mask_face, source_faces_index, gender_source, faces_index, gender_target, face_restorer_name, face_restorer_visibility, codeformer_weight, swap_in_source, swap_in_generated

View File

@ -309,7 +309,10 @@ class FaceSwapScript(scripts.Script):
if self.select_source == 2 or (self.select_source == 0 and self.source_imgs is not None and self.source is None): if self.select_source == 2 or (self.select_source == 0 and self.source_imgs is not None and self.source is None):
if len(result) > 0 and swapped > 0: if len(result) > 0 and swapped > 0:
if self.save_original:
result_images.extend(result) result_images.extend(result)
else:
result_images = result
suffix = "-swapped" suffix = "-swapped"
for i,x in enumerate(result): for i,x in enumerate(result):
try: try:

View File

@ -1,5 +1,5 @@
app_title = "ReActor" app_title = "ReActor"
version_flag = "v0.6.0-a1" version_flag = "v0.6.0-a2"
from scripts.reactor_logger import logger, get_Run, set_Run from scripts.reactor_logger import logger, get_Run, set_Run