diff --git a/imaginairy/api.py b/imaginairy/api.py index 3867a6b..f89ae05 100755 --- a/imaginairy/api.py +++ b/imaginairy/api.py @@ -330,13 +330,10 @@ def imagine( if prompt.fix_faces: logger.info(" Fixing 😊 's in 🖼 using CodeFormer...") - img = enhance_faces(img, fidelity=0.2) + img = enhance_faces(img, fidelity=prompt.fix_faces_fidelity) if prompt.upscale: logger.info(" Upscaling 🖼 using real-ESRGAN...") upscaled_img = upscale_image(img) - if prompt.fix_faces: - logger.info(" Fixing 😊 's in big 🖼 using CodeFormer...") - upscaled_img = enhance_faces(upscaled_img, fidelity=0.8) # put the newly generated patch back into the original, full size image if ( diff --git a/imaginairy/cmds.py b/imaginairy/cmds.py index 48fc2a0..c5291e2 100644 --- a/imaginairy/cmds.py +++ b/imaginairy/cmds.py @@ -99,6 +99,11 @@ def configure_logging(level="INFO"): ) @click.option("--upscale", is_flag=True) @click.option("--fix-faces", is_flag=True) +@click.option( + "--fix-faces-fidelity", + default=None, + help="How faithful to the original should face enhancement be. 1 = best fidelity, 0 = best looking face", +) @click.option( "--sampler-type", default="plms", @@ -183,6 +188,7 @@ def imagine_cmd( seed, upscale, fix_faces, + fix_faces_fidelity, sampler_type, ddim_eta, log_level, @@ -214,7 +220,8 @@ def imagine_cmd( if mask_image and mask_image.startswith("http"): mask_image = LazyLoadingImage(url=mask_image) - + if fix_faces_fidelity is not None: + fix_faces_fidelity = float(fix_faces_fidelity) prompts = [] load_model() for _ in range(repeats): @@ -235,6 +242,7 @@ def imagine_cmd( mask_modify_original=mask_modify_original, upscale=upscale, fix_faces=fix_faces, + fix_faces_fidelity=fix_faces_fidelity, tile_mode=tile, ) prompts.append(prompt) diff --git a/imaginairy/schema.py b/imaginairy/schema.py index 1ed797b..fdb9aa5 100644 --- a/imaginairy/schema.py +++ b/imaginairy/schema.py @@ -102,6 +102,7 @@ class ImaginePrompt: width=512, upscale=False, fix_faces=False, + fix_faces_fidelity=0.5, sampler_type="PLMS", conditioning=None, tile_mode=False, @@ -130,6 +131,7 @@ class ImaginePrompt: self.width = width self.upscale = upscale self.fix_faces = fix_faces + self.fix_faces_fidelity = fix_faces_fidelity self.sampler_type = sampler_type self.conditioning = conditioning self.mask_prompt = mask_prompt