fix bugs, fix api, clear code
This commit is contained in:
@@ -14,6 +14,7 @@ from scripts.faceswaplab_swapping import swapper
|
||||
|
||||
def img2img_diffusion(img: Image.Image, pp: PostProcessingOptions) -> Image.Image:
|
||||
if pp.inpainting_denoising_strengh == 0:
|
||||
logger.info("Discard inpainting denoising strength is 0")
|
||||
return img
|
||||
|
||||
try:
|
||||
@@ -25,7 +26,7 @@ inpainting_steps : {pp.inpainting_steps}
|
||||
"""
|
||||
)
|
||||
if not isinstance(pp.inpainting_sampler, str):
|
||||
pass
|
||||
pp.inpainting_sampler = "Euler"
|
||||
|
||||
logger.info("send faces to image to image")
|
||||
img = img.copy()
|
||||
|
||||
@@ -11,17 +11,32 @@ from scripts.faceswaplab_postprocessing.upscaling import upscale_img, restore_fa
|
||||
def enhance_image(image: Image.Image, pp_options: PostProcessingOptions) -> Image.Image:
|
||||
result_image = image
|
||||
try:
|
||||
if pp_options.inpainting_when == InpaintingWhen.BEFORE_UPSCALING.value:
|
||||
result_image = img2img_diffusion(image, pp_options)
|
||||
logger.debug("enhance_image, inpainting : %s", pp_options.inpainting_when)
|
||||
result_image = image
|
||||
|
||||
if (
|
||||
pp_options.inpainting_when == InpaintingWhen.BEFORE_UPSCALING.value
|
||||
or pp_options.inpainting_when == InpaintingWhen.BEFORE_UPSCALING
|
||||
):
|
||||
logger.debug("Inpaint before upscale")
|
||||
result_image = img2img_diffusion(result_image, pp_options)
|
||||
result_image = upscale_img(result_image, pp_options)
|
||||
|
||||
if pp_options.inpainting_when == InpaintingWhen.BEFORE_RESTORE_FACE.value:
|
||||
result_image = img2img_diffusion(image, pp_options)
|
||||
if (
|
||||
pp_options.inpainting_when == InpaintingWhen.BEFORE_RESTORE_FACE.value
|
||||
or pp_options.inpainting_when == InpaintingWhen.BEFORE_RESTORE_FACE
|
||||
):
|
||||
logger.debug("Inpaint before restore")
|
||||
result_image = img2img_diffusion(result_image, pp_options)
|
||||
|
||||
result_image = restore_face(result_image, pp_options)
|
||||
|
||||
if pp_options.inpainting_when == InpaintingWhen.AFTER_ALL.value:
|
||||
result_image = img2img_diffusion(image, pp_options)
|
||||
if (
|
||||
pp_options.inpainting_when == InpaintingWhen.AFTER_ALL.value
|
||||
or pp_options.inpainting_when == InpaintingWhen.AFTER_ALL
|
||||
):
|
||||
logger.debug("Inpaint after all")
|
||||
result_image = img2img_diffusion(result_image, pp_options)
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Failed to upscale %s", e)
|
||||
|
||||
@@ -19,7 +19,7 @@ class PostProcessingOptions:
|
||||
codeformer_weight: float = 1
|
||||
|
||||
upscaler_name: str = ""
|
||||
scale: int = 1
|
||||
scale: float = 1
|
||||
upscale_visibility: float = 0.5
|
||||
|
||||
inpainting_denoising_strengh: float = 0
|
||||
|
||||
Reference in New Issue
Block a user