Revert Prev + FIX: API Scale->Float

This commit is contained in:
Gourieff 2023-12-19 12:23:03 +07:00
parent 3b50def406
commit ed66d91819
6 changed files with 16 additions and 20 deletions

View File

@ -31,7 +31,7 @@ args=[
1, #5 Restore visibility value
True, #7 Restore face -> Upscale
'4x_NMKD-Superscale-SP_178000_G', #8 Upscaler (type 'None' if doesn't need), see full list here: http://127.0.0.1:7860/sdapi/v1/script-info -> reactor -> sec.8
2, #9 Upscaler scale value
1.5, #9 Upscaler scale value
1, #10 Upscaler visibility (if scale = 1)
False, #11 Swap in source image
True, #12 Swap in generated image

View File

@ -8,7 +8,7 @@ curl -X POST \
"source_faces_index": [0],
"face_index": [2],
"upscaler": "None",
"scale": 1,
"scale": 1.5,
"upscale_visibility": 1,
"face_restorer": "CodeFormer",
"restorer_visibility": 1,

View File

@ -4,7 +4,7 @@
"source_faces_index": [0],
"face_index": [2],
"upscaler": "None",
"scale": 1,
"scale": 1.5,
"upscale_visibility": 1,
"face_restorer": "CodeFormer",
"restorer_visibility": 1,

View File

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

@ -60,7 +60,7 @@ def reactor_api(_: gr.Blocks, app: FastAPI):
source_faces_index: list[int] = Body([0],title="Comma separated face number(s) from swap-source image"),
face_index: list[int] = Body([0],title="Comma separated face number(s) for target image (result)"),
upscaler: str = Body("None",title="Upscaler"),
scale: int = Body(1,title="Scale by"),
scale: float = Body(1,title="Scale by"),
upscale_visibility: float = Body(1,title="Upscaler visibility (if scale = 1)"),
face_restorer: str = Body("None",title="Restore Face: 0 - None; 1 - CodeFormer; 2 - GFPGA"),
restorer_visibility: float = Body(1,title="Restore visibility value"),

View File

@ -309,10 +309,7 @@ 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 len(result) > 0 and swapped > 0:
if self.save_original:
result_images.extend(result)
else:
result_images = result
result_images.extend(result)
suffix = "-swapped"
for i,x in enumerate(result):
try: