UPDATE: Old SD.WebUI < 1.7.0 support

This commit is contained in:
Art Gourieff 2024-04-07 01:25:13 +07:00
parent 97598387b1
commit 7633e58182

View File

@ -6,7 +6,7 @@ from typing import List
import modules.scripts as scripts import modules.scripts as scripts
from modules.upscaler import Upscaler, UpscalerData from modules.upscaler import Upscaler, UpscalerData
from modules import scripts, shared, images, scripts_postprocessing, ui_components from modules import scripts, shared, images, scripts_postprocessing
from modules.processing import ( from modules.processing import (
Processed, Processed,
StableDiffusionProcessing, StableDiffusionProcessing,
@ -39,6 +39,20 @@ from scripts.reactor_helpers import (
) )
from scripts.reactor_globals import SWAPPER_MODELS_PATH #, DEVICE, DEVICE_LIST from scripts.reactor_globals import SWAPPER_MODELS_PATH #, DEVICE, DEVICE_LIST
def IA_cap(cond: bool, label: str=""):
return None
try:
from modules.ui_components import InputAccordion
NO_IA = False
except:
NO_IA = True
InputAccordion = IA_cap
def check_old_webui():
return NO_IA
class FaceSwapScript(scripts.Script): class FaceSwapScript(scripts.Script):
def title(self): def title(self):
@ -48,19 +62,12 @@ class FaceSwapScript(scripts.Script):
return scripts.AlwaysVisible return scripts.AlwaysVisible
def ui(self, is_img2img): def ui(self, is_img2img):
with ui_components.InputAccordion(False, label=f"{app_title}") as enable: with (
# with gr.Accordion(f"{app_title}", open=False): gr.Accordion(f"{app_title}", open=False) if check_old_webui() else InputAccordion(False, label=f"{app_title}") as enable
):
# def on_files_upload_uncheck_so(selected: bool): # SD.Next or A1111 1.52:
# global SAVE_ORIGINAL if get_SDNEXT() or check_old_webui():
# SAVE_ORIGINAL = selected
# return gr.Checkbox.update(value=False,visible=False)
# def on_files_clear():
# clear_faces_list()
# return gr.Checkbox.update(value=SAVE_ORIGINAL,visible=True)
# SD.Next fix
if get_SDNEXT():
enable = gr.Checkbox(False, label="Enable") enable = gr.Checkbox(False, label="Enable")
# enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}") # enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}")
@ -488,11 +495,14 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
order = 20000 order = 20000
def ui(self): def ui(self):
with ui_components.InputAccordion(False, label=f"{app_title}") as enable: with (
gr.Accordion(f"{app_title}", open=False) if check_old_webui() else InputAccordion(False, label=f"{app_title}") as enable
):
# with ui_components.InputAccordion(False, label=f"{app_title}") as enable:
# with gr.Accordion(f"{app_title}", open=False): # with gr.Accordion(f"{app_title}", open=False):
# SD.Next fix # SD.Next or A1111 1.52:
if get_SDNEXT(): if get_SDNEXT() or check_old_webui():
enable = gr.Checkbox(False, label="Enable") enable = gr.Checkbox(False, label="Enable")
# enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}") # enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}")