Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 806086b533 | |||
| 38f46d3f01 | |||
| 9977168136 | |||
| 2e718ee4ae | |||
| d0c56ae6ef | |||
| c4badb7894 | |||
| 54adcc0fc6 |
@@ -1,3 +1,13 @@
|
|||||||
|
# 1.2.5
|
||||||
|
|
||||||
|
Allow seed selection in inpainting.
|
||||||
|
|
||||||
|
# 1.2.4
|
||||||
|
|
||||||
|
Fix default settings by marking only managed field as do_not_save.
|
||||||
|
|
||||||
|
See the discussion here : https://github.com/glucauze/sd-webui-faceswaplab/issues/62
|
||||||
|
|
||||||
# 1.2.3
|
# 1.2.3
|
||||||
|
|
||||||
Speed up ui : change the way default settings are manage by not storing them in ui-config.json
|
Speed up ui : change the way default settings are manage by not storing them in ui-config.json
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class InpaintingOptions(BaseModel):
|
|||||||
inpainting_model: str = Field(
|
inpainting_model: str = Field(
|
||||||
description="Inpainting model", examples=["Current"], default="Current"
|
description="Inpainting model", examples=["Current"], default="Current"
|
||||||
)
|
)
|
||||||
|
inpainting_seed: int = Field(description="Inpainting Seed", ge=-1, default=-1)
|
||||||
|
|
||||||
|
|
||||||
class InswappperOptions(BaseModel):
|
class InswappperOptions(BaseModel):
|
||||||
|
|||||||
Binary file not shown.
+8
-2
@@ -2,12 +2,18 @@ import launch
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from modules import shared
|
|
||||||
from packaging.version import parse
|
from packaging.version import parse
|
||||||
|
|
||||||
|
|
||||||
def check_install() -> None:
|
def check_install() -> None:
|
||||||
use_gpu = not getattr(shared.cmd_opts, "use-cpu", False)
|
use_gpu = True
|
||||||
|
try:
|
||||||
|
from modules import shared
|
||||||
|
|
||||||
|
use_gpu = not getattr(shared.cmd_opts, "use-cpu", False)
|
||||||
|
except:
|
||||||
|
# On some platform previous lines may failed (modules.shared not initialized), just ignore and use GPU requirements
|
||||||
|
pass
|
||||||
|
|
||||||
if use_gpu and sys.platform != "darwin":
|
if use_gpu and sys.platform != "darwin":
|
||||||
print("Faceswaplab : Use GPU requirements")
|
print("Faceswaplab : Use GPU requirements")
|
||||||
|
|||||||
@@ -8,8 +8,3 @@ def preload(parser: ArgumentParser) -> None:
|
|||||||
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
||||||
help="Set the log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
help="Set the log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--faceswaplab_gpu",
|
|
||||||
action="store_true",
|
|
||||||
help="Enable GPU if set, disable if not set",
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -111,9 +111,6 @@ class FaceSwapScript(scripts.Script):
|
|||||||
# If the order is modified, the before_process should be changed accordingly.
|
# If the order is modified, the before_process should be changed accordingly.
|
||||||
|
|
||||||
components = components + post_processing
|
components = components + post_processing
|
||||||
# Ask sd to not store in ui-config.json
|
|
||||||
for component in components:
|
|
||||||
setattr(component, "do_not_save_to_config", True)
|
|
||||||
|
|
||||||
return components
|
return components
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ REFERENCE_PATH = os.path.join(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Defining the version flag for the application
|
# Defining the version flag for the application
|
||||||
VERSION_FLAG: str = "v1.2.3"
|
VERSION_FLAG: str = "v1.2.5"
|
||||||
# Defining the path for 'sd-webui-faceswaplab' inside the 'extensions' directory
|
# Defining the path for 'sd-webui-faceswaplab' inside the 'extensions' directory
|
||||||
EXTENSION_PATH = os.path.join("extensions", "sd-webui-faceswaplab")
|
EXTENSION_PATH = os.path.join("extensions", "sd-webui-faceswaplab")
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class InpaintingOptions:
|
|||||||
inpainting_steps: int = 20
|
inpainting_steps: int = 20
|
||||||
inpainting_sampler: str = "Euler"
|
inpainting_sampler: str = "Euler"
|
||||||
inpainting_model: str = "Current"
|
inpainting_model: str = "Current"
|
||||||
|
inpainting_seed: int = -1
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_gradio(components: List[gr.components.Component]) -> "InpaintingOptions":
|
def from_gradio(components: List[gr.components.Component]) -> "InpaintingOptions":
|
||||||
@@ -38,4 +39,5 @@ class InpaintingOptions:
|
|||||||
inpainting_steps=dto.inpainting_steps,
|
inpainting_steps=dto.inpainting_steps,
|
||||||
inpainting_sampler=dto.inpainting_sampler,
|
inpainting_sampler=dto.inpainting_sampler,
|
||||||
inpainting_model=dto.inpainting_model,
|
inpainting_model=dto.inpainting_model,
|
||||||
|
inpainting_seed=dto.inpainting_seed,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -63,16 +63,19 @@ inpainting_steps : {options.inpainting_steps}
|
|||||||
"prompt": prompt,
|
"prompt": prompt,
|
||||||
"negative_prompt": negative_prompt,
|
"negative_prompt": negative_prompt,
|
||||||
"denoising_strength": options.inpainting_denoising_strengh,
|
"denoising_strength": options.inpainting_denoising_strengh,
|
||||||
"override_settings": {
|
"seed": options.inpainting_seed,
|
||||||
"return_mask_composite": False,
|
|
||||||
"save_images_before_face_restoration": False,
|
|
||||||
"save_images_before_highres_fix": False,
|
|
||||||
"save_images_before_color_correction": False,
|
|
||||||
"save_mask": False,
|
|
||||||
"save_mask_composite": False,
|
|
||||||
"samples_save": False,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
# Remove the following as they are not always supported on all platform :
|
||||||
|
# "override_settings": {
|
||||||
|
# "return_mask_composite": False,
|
||||||
|
# "save_images_before_face_restoration": False,
|
||||||
|
# "save_images_before_highres_fix": False,
|
||||||
|
# "save_images_before_color_correction": False,
|
||||||
|
# "save_mask": False,
|
||||||
|
# "save_mask_composite": False,
|
||||||
|
# "samples_save": False,
|
||||||
|
# },
|
||||||
|
|
||||||
current_model_checkpoint = shared.opts.sd_model_checkpoint
|
current_model_checkpoint = shared.opts.sd_model_checkpoint
|
||||||
if options.inpainting_model and options.inpainting_model != "Current":
|
if options.inpainting_model and options.inpainting_model != "Current":
|
||||||
# Change checkpoint
|
# Change checkpoint
|
||||||
|
|||||||
@@ -4,65 +4,71 @@ from modules import sd_models, sd_samplers
|
|||||||
from scripts.faceswaplab_utils.sd_utils import get_sd_option
|
from scripts.faceswaplab_utils.sd_utils import get_sd_option
|
||||||
|
|
||||||
|
|
||||||
def face_inpainting_ui(
|
def face_inpainting_ui(id_prefix: str = "faceswaplab") -> List[gr.components.Component]:
|
||||||
name: str, id_prefix: str = "faceswaplab", description: str = ""
|
inpainting_denoising_strength = gr.Slider(
|
||||||
) -> List[gr.components.Component]:
|
0,
|
||||||
with gr.Accordion(name, open=False):
|
1,
|
||||||
gr.Markdown(description)
|
0,
|
||||||
inpainting_denoising_strength = gr.Slider(
|
step=0.01,
|
||||||
0,
|
elem_id=f"{id_prefix}_pp_inpainting_denoising_strength",
|
||||||
|
label="Denoising strenght",
|
||||||
|
)
|
||||||
|
|
||||||
|
inpainting_denoising_prompt = gr.Textbox(
|
||||||
|
get_sd_option(
|
||||||
|
"faceswaplab_pp_default_inpainting_prompt", "Portrait of a [gender]"
|
||||||
|
),
|
||||||
|
elem_id=f"{id_prefix}_pp_inpainting_denoising_prompt",
|
||||||
|
label="Inpainting prompt use [gender] instead of men or woman",
|
||||||
|
)
|
||||||
|
inpainting_denoising_negative_prompt = gr.Textbox(
|
||||||
|
get_sd_option("faceswaplab_pp_default_inpainting_negative_prompt", "blurry"),
|
||||||
|
elem_id=f"{id_prefix}_pp_inpainting_denoising_neg_prompt",
|
||||||
|
label="Inpainting negative prompt use [gender] instead of men or woman",
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
samplers_names = [s.name for s in sd_samplers.all_samplers]
|
||||||
|
inpainting_sampler = gr.Dropdown(
|
||||||
|
choices=samplers_names,
|
||||||
|
value=[samplers_names[0]],
|
||||||
|
label="Inpainting Sampler",
|
||||||
|
elem_id=f"{id_prefix}_pp_inpainting_sampler",
|
||||||
|
)
|
||||||
|
inpainting_denoising_steps = gr.Slider(
|
||||||
1,
|
1,
|
||||||
0,
|
150,
|
||||||
step=0.01,
|
20,
|
||||||
elem_id=f"{id_prefix}_pp_inpainting_denoising_strength",
|
step=1,
|
||||||
label="Denoising strenght",
|
label="Inpainting steps",
|
||||||
|
elem_id=f"{id_prefix}_pp_inpainting_steps",
|
||||||
)
|
)
|
||||||
|
|
||||||
inpainting_denoising_prompt = gr.Textbox(
|
inpaiting_model = gr.Dropdown(
|
||||||
get_sd_option(
|
choices=["Current"] + sd_models.checkpoint_tiles(),
|
||||||
"faceswaplab_pp_default_inpainting_prompt", "Portrait of a [gender]"
|
default="Current",
|
||||||
),
|
label="sd model (experimental)",
|
||||||
elem_id=f"{id_prefix}_pp_inpainting_denoising_prompt",
|
elem_id=f"{id_prefix}_pp_inpainting_sd_model",
|
||||||
label="Inpainting prompt use [gender] instead of men or woman",
|
)
|
||||||
)
|
|
||||||
inpainting_denoising_negative_prompt = gr.Textbox(
|
|
||||||
get_sd_option(
|
|
||||||
"faceswaplab_pp_default_inpainting_negative_prompt", "blurry"
|
|
||||||
),
|
|
||||||
elem_id=f"{id_prefix}_pp_inpainting_denoising_neg_prompt",
|
|
||||||
label="Inpainting negative prompt use [gender] instead of men or woman",
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
samplers_names = [s.name for s in sd_samplers.all_samplers]
|
|
||||||
inpainting_sampler = gr.Dropdown(
|
|
||||||
choices=samplers_names,
|
|
||||||
value=[samplers_names[0]],
|
|
||||||
label="Inpainting Sampler",
|
|
||||||
elem_id=f"{id_prefix}_pp_inpainting_sampler",
|
|
||||||
)
|
|
||||||
inpainting_denoising_steps = gr.Slider(
|
|
||||||
1,
|
|
||||||
150,
|
|
||||||
20,
|
|
||||||
step=1,
|
|
||||||
label="Inpainting steps",
|
|
||||||
elem_id=f"{id_prefix}_pp_inpainting_steps",
|
|
||||||
)
|
|
||||||
|
|
||||||
inpaiting_model = gr.Dropdown(
|
inpaiting_seed = gr.Number(
|
||||||
choices=["Current"] + sd_models.checkpoint_tiles(),
|
label="Inpainting seed",
|
||||||
default="Current",
|
value=0,
|
||||||
label="sd model (experimental)",
|
minimum=0,
|
||||||
elem_id=f"{id_prefix}_pp_inpainting_sd_model",
|
precision=0,
|
||||||
)
|
elem_id=f"{id_prefix}_pp_inpainting_seed",
|
||||||
|
)
|
||||||
|
|
||||||
gradio_components: List[gr.components.Component] = [
|
gradio_components: List[gr.components.Component] = [
|
||||||
inpainting_denoising_strength,
|
inpainting_denoising_strength,
|
||||||
inpainting_denoising_prompt,
|
inpainting_denoising_prompt,
|
||||||
inpainting_denoising_negative_prompt,
|
inpainting_denoising_negative_prompt,
|
||||||
inpainting_denoising_steps,
|
inpainting_denoising_steps,
|
||||||
inpainting_sampler,
|
inpainting_sampler,
|
||||||
inpaiting_model,
|
inpaiting_model,
|
||||||
]
|
inpaiting_seed,
|
||||||
|
]
|
||||||
|
|
||||||
return gradio_components
|
for component in gradio_components:
|
||||||
|
setattr(component, "do_not_save_to_config", True)
|
||||||
|
|
||||||
|
return gradio_components
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import modules
|
|||||||
from modules import shared, sd_models
|
from modules import shared, sd_models
|
||||||
from scripts.faceswaplab_postprocessing.postprocessing_options import InpaintingWhen
|
from scripts.faceswaplab_postprocessing.postprocessing_options import InpaintingWhen
|
||||||
from scripts.faceswaplab_utils.sd_utils import get_sd_option
|
from scripts.faceswaplab_utils.sd_utils import get_sd_option
|
||||||
|
from scripts.faceswaplab_ui.faceswaplab_inpainting_ui import face_inpainting_ui
|
||||||
|
|
||||||
|
|
||||||
def postprocessing_ui() -> List[gr.components.Component]:
|
def postprocessing_ui() -> List[gr.components.Component]:
|
||||||
@@ -66,9 +67,10 @@ def postprocessing_ui() -> List[gr.components.Component]:
|
|||||||
label="Upscaler visibility (if scale = 1)",
|
label="Upscaler visibility (if scale = 1)",
|
||||||
elem_id="faceswaplab_pp_upscaler_visibility",
|
elem_id="faceswaplab_pp_upscaler_visibility",
|
||||||
)
|
)
|
||||||
with gr.Accordion(f"Post Inpainting", open=True):
|
|
||||||
|
with gr.Accordion(label="Global-Inpainting (all faces)", open=False):
|
||||||
gr.Markdown(
|
gr.Markdown(
|
||||||
"""Inpainting sends image to inpainting with a mask on face (once for each faces)."""
|
"Inpainting sends image to inpainting with a mask on face (once for each faces)."
|
||||||
)
|
)
|
||||||
inpainting_when = gr.Dropdown(
|
inpainting_when = gr.Dropdown(
|
||||||
elem_id="faceswaplab_pp_inpainting_when",
|
elem_id="faceswaplab_pp_inpainting_when",
|
||||||
@@ -76,52 +78,8 @@ def postprocessing_ui() -> List[gr.components.Component]:
|
|||||||
value=[InpaintingWhen.BEFORE_RESTORE_FACE.value],
|
value=[InpaintingWhen.BEFORE_RESTORE_FACE.value],
|
||||||
label="Enable/When",
|
label="Enable/When",
|
||||||
)
|
)
|
||||||
inpainting_denoising_strength = gr.Slider(
|
global_inpainting = face_inpainting_ui("faceswaplab_gpp")
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
step=0.01,
|
|
||||||
elem_id="faceswaplab_pp_inpainting_denoising_strength",
|
|
||||||
label="Denoising strenght (will send face to img2img after processing)",
|
|
||||||
)
|
|
||||||
|
|
||||||
inpainting_denoising_prompt = gr.Textbox(
|
|
||||||
get_sd_option(
|
|
||||||
"faceswaplab_pp_default_inpainting_prompt", "Portrait of a [gender]"
|
|
||||||
),
|
|
||||||
elem_id="faceswaplab_pp_inpainting_denoising_prompt",
|
|
||||||
label="Inpainting prompt use [gender] instead of men or woman",
|
|
||||||
)
|
|
||||||
inpainting_denoising_negative_prompt = gr.Textbox(
|
|
||||||
get_sd_option(
|
|
||||||
"faceswaplab_pp_default_inpainting_negative_prompt", "blurry"
|
|
||||||
),
|
|
||||||
elem_id="faceswaplab_pp_inpainting_denoising_neg_prompt",
|
|
||||||
label="Inpainting negative prompt use [gender] instead of men or woman",
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
samplers_names = [s.name for s in modules.sd_samplers.all_samplers] # type: ignore
|
|
||||||
inpainting_sampler = gr.Dropdown(
|
|
||||||
choices=samplers_names,
|
|
||||||
value=[samplers_names[0]],
|
|
||||||
label="Inpainting Sampler",
|
|
||||||
elem_id="faceswaplab_pp_inpainting_sampler",
|
|
||||||
)
|
|
||||||
inpainting_denoising_steps = gr.Slider(
|
|
||||||
1,
|
|
||||||
150,
|
|
||||||
20,
|
|
||||||
step=1,
|
|
||||||
label="Inpainting steps",
|
|
||||||
elem_id="faceswaplab_pp_inpainting_steps",
|
|
||||||
)
|
|
||||||
|
|
||||||
inpaiting_model = gr.Dropdown(
|
|
||||||
choices=["Current"] + sd_models.checkpoint_tiles(),
|
|
||||||
default="Current",
|
|
||||||
label="sd model (experimental)",
|
|
||||||
elem_id="faceswaplab_pp_inpainting_sd_model",
|
|
||||||
)
|
|
||||||
components = [
|
components = [
|
||||||
face_restorer_name,
|
face_restorer_name,
|
||||||
face_restorer_visibility,
|
face_restorer_visibility,
|
||||||
@@ -130,13 +88,7 @@ def postprocessing_ui() -> List[gr.components.Component]:
|
|||||||
upscaler_scale,
|
upscaler_scale,
|
||||||
upscaler_visibility,
|
upscaler_visibility,
|
||||||
inpainting_when,
|
inpainting_when,
|
||||||
inpainting_denoising_strength,
|
] + global_inpainting
|
||||||
inpainting_denoising_prompt,
|
|
||||||
inpainting_denoising_negative_prompt,
|
|
||||||
inpainting_denoising_steps,
|
|
||||||
inpainting_sampler,
|
|
||||||
inpaiting_model,
|
|
||||||
]
|
|
||||||
|
|
||||||
# Ask sd to not store in ui-config.json
|
# Ask sd to not store in ui-config.json
|
||||||
for component in components:
|
for component in components:
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ def faceswap_unit_advanced_options(
|
|||||||
elem_id=f"{id_prefix}_face{unit_num}_erosion_factor",
|
elem_id=f"{id_prefix}_face{unit_num}_erosion_factor",
|
||||||
)
|
)
|
||||||
|
|
||||||
return [
|
components = [
|
||||||
face_restorer_name,
|
face_restorer_name,
|
||||||
face_restorer_visibility,
|
face_restorer_visibility,
|
||||||
codeformer_weight,
|
codeformer_weight,
|
||||||
@@ -91,6 +91,11 @@ def faceswap_unit_advanced_options(
|
|||||||
erosion_factor,
|
erosion_factor,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
for component in components:
|
||||||
|
setattr(component, "do_not_save_to_config", True)
|
||||||
|
|
||||||
|
return components
|
||||||
|
|
||||||
|
|
||||||
def faceswap_unit_ui(
|
def faceswap_unit_ui(
|
||||||
is_img2img: bool, unit_num: int = 1, id_prefix: str = "faceswaplab"
|
is_img2img: bool, unit_num: int = 1, id_prefix: str = "faceswaplab"
|
||||||
@@ -244,19 +249,19 @@ Otherwise, read the [doc](https://glucauze.github.io/sd-webui-faceswaplab/doc/)
|
|||||||
elem_id=f"{id_prefix}_face{unit_num}_min_ref_similarity",
|
elem_id=f"{id_prefix}_face{unit_num}_min_ref_similarity",
|
||||||
)
|
)
|
||||||
|
|
||||||
pre_inpainting = face_inpainting_ui(
|
with gr.Accordion(label="Pre-Inpainting (before swapping)", open=False):
|
||||||
name="Pre-Inpainting (Before swapping)",
|
gr.Markdown("Pre-inpainting sends face to inpainting before swapping")
|
||||||
id_prefix=f"{id_prefix}_face{unit_num}_preinpainting",
|
pre_inpainting = face_inpainting_ui(
|
||||||
description="Pre-inpainting sends face to inpainting before swapping",
|
id_prefix=f"{id_prefix}_face{unit_num}_preinpainting",
|
||||||
)
|
)
|
||||||
|
|
||||||
options = faceswap_unit_advanced_options(is_img2img, unit_num, id_prefix)
|
options = faceswap_unit_advanced_options(is_img2img, unit_num, id_prefix)
|
||||||
|
|
||||||
post_inpainting = face_inpainting_ui(
|
with gr.Accordion(label="Post-Inpainting (After swapping)", open=False):
|
||||||
name="Post-Inpainting (After swapping)",
|
gr.Markdown("Pre-inpainting sends face to inpainting before swapping")
|
||||||
id_prefix=f"{id_prefix}_face{unit_num}_postinpainting",
|
post_inpainting = face_inpainting_ui(
|
||||||
description="Post-inpainting sends face to inpainting after swapping",
|
id_prefix=f"{id_prefix}_face{unit_num}_postinpainting",
|
||||||
)
|
)
|
||||||
|
|
||||||
gradio_components: List[gr.components.Component] = (
|
gradio_components: List[gr.components.Component] = (
|
||||||
[
|
[
|
||||||
@@ -281,10 +286,6 @@ Otherwise, read the [doc](https://glucauze.github.io/sd-webui-faceswaplab/doc/)
|
|||||||
+ post_inpainting
|
+ post_inpainting
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ask sd to not store in ui-config.json
|
|
||||||
for component in gradio_components:
|
|
||||||
setattr(component, "do_not_save_to_config", True)
|
|
||||||
|
|
||||||
# If changed, you need to change FaceSwapUnitSettings accordingly
|
# If changed, you need to change FaceSwapUnitSettings accordingly
|
||||||
# ORDER of parameters is IMPORTANT. It should match the result of FaceSwapUnitSettings
|
# ORDER of parameters is IMPORTANT. It should match the result of FaceSwapUnitSettings
|
||||||
return gradio_components
|
return gradio_components
|
||||||
|
|||||||
Reference in New Issue
Block a user