Merge branch 'equalize' into evolve
This commit is contained in:
commit
9b0cc02791
@ -85,16 +85,21 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
|
|||||||
imgs_hash_clear.click(clear_faces_list,None,[progressbar_area])
|
imgs_hash_clear.click(clear_faces_list,None,[progressbar_area])
|
||||||
gr.Markdown("<br>", visible=show_br)
|
gr.Markdown("<br>", visible=show_br)
|
||||||
with gr.Column(visible=True) as control_col_1:
|
with gr.Column(visible=True) as control_col_1:
|
||||||
gr.Markdown("<center>🔽🔽🔽 Single Image has priority when both Areas in use 🔽🔽🔽</center>")
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
img = gr.Image(
|
selected_tab = gr.Textbox('tab_single', visible=False)
|
||||||
type="pil",
|
with gr.Tabs() as tab_single:
|
||||||
label="Single Source Image",
|
with gr.Tab('Single'):
|
||||||
)
|
img = gr.Image(
|
||||||
imgs = gr.Files(
|
type="pil",
|
||||||
label=f"Multiple Source Images{msgs['extra_multiple_source']}",
|
label="Single Source Image",
|
||||||
file_types=["image"],
|
)
|
||||||
)
|
with gr.Tab('Multiple') as tab_multiple:
|
||||||
|
imgs = gr.Files(
|
||||||
|
label=f"Multiple Source Images{msgs['extra_multiple_source']}",
|
||||||
|
file_types=["image"],
|
||||||
|
)
|
||||||
|
tab_single.select(fn=lambda: 'tab_single', inputs=[], outputs=[selected_tab])
|
||||||
|
tab_multiple.select(fn=lambda: 'tab_multiple', inputs=[], outputs=[selected_tab])
|
||||||
with gr.Column(visible=False) as control_col_3:
|
with gr.Column(visible=False) as control_col_3:
|
||||||
gr.Markdown("<span style='display:block;text-align:right;padding-right:3px;margin: -15px 0;font-size:1.1em'><sup>Clear Hash if you see the previous face was swapped instead of the new one</sup></span>")
|
gr.Markdown("<span style='display:block;text-align:right;padding-right:3px;margin: -15px 0;font-size:1.1em'><sup>Clear Hash if you see the previous face was swapped instead of the new one</sup></span>")
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
@ -189,4 +194,4 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
|
|||||||
# 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,[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)
|
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, random_image
|
return img, imgs, selected_tab, 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, random_image
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
albumentations==1.4.3
|
||||||
insightface==0.7.3
|
insightface==0.7.3
|
||||||
onnx>=1.14.0
|
onnx>=1.14.0
|
||||||
opencv-python>=4.7.0.72
|
opencv-python>=4.7.0.72
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class FaceSwapScript(scripts.Script):
|
|||||||
msgs: dict = {
|
msgs: dict = {
|
||||||
"extra_multiple_source": "",
|
"extra_multiple_source": "",
|
||||||
}
|
}
|
||||||
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, random_image = ui_main.show(is_img2img=is_img2img, **msgs)
|
img, imgs, selected_tab, 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, random_image = ui_main.show(is_img2img=is_img2img, **msgs)
|
||||||
|
|
||||||
# TAB DETECTION
|
# TAB DETECTION
|
||||||
det_thresh, det_maxnum = ui_detection.show()
|
det_thresh, det_maxnum = ui_detection.show()
|
||||||
@ -123,7 +123,8 @@ class FaceSwapScript(scripts.Script):
|
|||||||
random_image,
|
random_image,
|
||||||
upscale_force,
|
upscale_force,
|
||||||
det_thresh,
|
det_thresh,
|
||||||
det_maxnum
|
det_maxnum,
|
||||||
|
selected_tab,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -193,7 +194,8 @@ class FaceSwapScript(scripts.Script):
|
|||||||
random_image,
|
random_image,
|
||||||
upscale_force,
|
upscale_force,
|
||||||
det_thresh,
|
det_thresh,
|
||||||
det_maxnum
|
det_maxnum,
|
||||||
|
selected_tab,
|
||||||
):
|
):
|
||||||
self.enable = enable
|
self.enable = enable
|
||||||
if self.enable:
|
if self.enable:
|
||||||
@ -205,7 +207,10 @@ class FaceSwapScript(scripts.Script):
|
|||||||
return
|
return
|
||||||
|
|
||||||
global SWAPPER_MODELS_PATH
|
global SWAPPER_MODELS_PATH
|
||||||
self.source = img
|
if selected_tab == "tab_single":
|
||||||
|
self.source = img
|
||||||
|
else:
|
||||||
|
self.source = None
|
||||||
self.face_restorer_name = face_restorer_name
|
self.face_restorer_name = face_restorer_name
|
||||||
self.upscaler_scale = upscaler_scale
|
self.upscaler_scale = upscaler_scale
|
||||||
self.upscaler_visibility = upscaler_visibility
|
self.upscaler_visibility = upscaler_visibility
|
||||||
@ -227,7 +232,10 @@ class FaceSwapScript(scripts.Script):
|
|||||||
self.select_source = select_source
|
self.select_source = select_source
|
||||||
self.face_model = face_model
|
self.face_model = face_model
|
||||||
self.source_folder = source_folder
|
self.source_folder = source_folder
|
||||||
self.source_imgs = imgs
|
if selected_tab == "tab_single":
|
||||||
|
self.source_imgs = None
|
||||||
|
else:
|
||||||
|
self.source_imgs = imgs
|
||||||
self.random_image = random_image
|
self.random_image = random_image
|
||||||
self.upscale_force = upscale_force
|
self.upscale_force = upscale_force
|
||||||
self.det_thresh=det_thresh
|
self.det_thresh=det_thresh
|
||||||
@ -510,9 +518,9 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
|
|||||||
|
|
||||||
# TAB MAIN
|
# TAB MAIN
|
||||||
msgs: dict = {
|
msgs: dict = {
|
||||||
"extra_multiple_source": " | Сomparison grid as a result",
|
"extra_multiple_source": "",
|
||||||
}
|
}
|
||||||
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, random_image = ui_main.show(is_img2img=False, show_br=False, **msgs)
|
img, imgs, selected_tab, 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, random_image = ui_main.show(is_img2img=False, show_br=False, **msgs)
|
||||||
|
|
||||||
# TAB DETECTION
|
# TAB DETECTION
|
||||||
det_thresh, det_maxnum = ui_detection.show()
|
det_thresh, det_maxnum = ui_detection.show()
|
||||||
@ -554,6 +562,7 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
|
|||||||
'upscale_force': upscale_force,
|
'upscale_force': upscale_force,
|
||||||
'det_thresh': det_thresh,
|
'det_thresh': det_thresh,
|
||||||
'det_maxnum': det_maxnum,
|
'det_maxnum': det_maxnum,
|
||||||
|
'selected_tab': selected_tab,
|
||||||
}
|
}
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -598,7 +607,10 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
|
|||||||
return
|
return
|
||||||
|
|
||||||
global SWAPPER_MODELS_PATH
|
global SWAPPER_MODELS_PATH
|
||||||
self.source = args['img']
|
if args['selected_tab'] == "tab_single":
|
||||||
|
self.source = args['img']
|
||||||
|
else:
|
||||||
|
self.source = None
|
||||||
self.face_restorer_name = args['face_restorer_name']
|
self.face_restorer_name = args['face_restorer_name']
|
||||||
self.upscaler_scale = args['upscaler_scale']
|
self.upscaler_scale = args['upscaler_scale']
|
||||||
self.upscaler_visibility = args['upscaler_visibility']
|
self.upscaler_visibility = args['upscaler_visibility']
|
||||||
@ -615,7 +627,10 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
|
|||||||
self.select_source = args['select_source']
|
self.select_source = args['select_source']
|
||||||
self.face_model = args['face_model']
|
self.face_model = args['face_model']
|
||||||
self.source_folder = args['source_folder']
|
self.source_folder = args['source_folder']
|
||||||
self.source_imgs = args['imgs']
|
if args['selected_tab'] == "tab_single":
|
||||||
|
self.source_imgs = None
|
||||||
|
else:
|
||||||
|
self.source_imgs = args['imgs']
|
||||||
self.random_image = args['random_image']
|
self.random_image = args['random_image']
|
||||||
self.upscale_force = args['upscale_force']
|
self.upscale_force = args['upscale_force']
|
||||||
self.det_thresh = args['det_thresh']
|
self.det_thresh = args['det_thresh']
|
||||||
@ -694,9 +709,13 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
|
|||||||
if len(result) > 0 and swapped > 0:
|
if len(result) > 0 and swapped > 0:
|
||||||
image = result[0]
|
image = result[0]
|
||||||
if len(result) > 1:
|
if len(result) > 1:
|
||||||
grid = make_grid(result)
|
if hasattr(pp, 'extra_images'):
|
||||||
result.insert(0, grid)
|
image = result[0]
|
||||||
image = grid
|
pp.extra_images.extend(result[1:])
|
||||||
|
else:
|
||||||
|
grid = make_grid(result)
|
||||||
|
result.insert(0, grid)
|
||||||
|
image = grid
|
||||||
pp.info["ReActor"] = True
|
pp.info["ReActor"] = True
|
||||||
pp.image = image
|
pp.image = image
|
||||||
logger.status("---Done!---")
|
logger.status("---Done!---")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user