diff --git a/README.md b/README.md index 31a614d..6a6bbd5 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ gradio_demo/app-multicontrolnet.py - For over-saturation, decrease the ip_adapter_scale. If not work, decrease controlnet_conditioning_scale. - For higher text control ability, decrease ip_adapter_scale. - For specific styles, choose corresponding base model makes differences. -- We have not supported multi-person yet, will only use the largest face as reference pose. +- We have not supported multi-person yet, only use the largest face as reference facial landmarks. - We provide a [style template](https://github.com/ahgsql/StyleSelectorXL/blob/main/sdxl_styles.json) for reference. ## Community Resources @@ -228,9 +228,6 @@ gradio_demo/app-multicontrolnet.py ## Disclaimer The code of InstantID is released under [Apache License](https://github.com/InstantID/InstantID?tab=Apache-2.0-1-ov-file#readme) for both academic and commercial usage. **However, both manual-downloading and auto-downloading face models from insightface are for non-commercial research purposes only** accoreding to their [license](https://github.com/deepinsight/insightface?tab=readme-ov-file#license). Users are granted the freedom to create images using this tool, but they are obligated to comply with local laws and utilize it responsibly. The developers will not assume any responsibility for potential misuse by users. -## Declaration -🚨🚨🚨 We solemnly clarify that [FAKE][FAKE][FAKE] http://instantid.org [FAKE][FAKE][FAKE] is not authorized and has no relationship with us. It is infringing and quite misleading, and has never contacted us for official cooperation. Please be aware of your personal privacy and subscription fraud. We reserve all legal rights. - ## Star History [![Star History Chart](https://api.star-history.com/svg?repos=InstantID/InstantID&type=Date)](https://star-history.com/#InstantID/InstantID&Date) diff --git a/gradio_demo/app-multicontrolnet.py b/gradio_demo/app-multicontrolnet.py index 5d60e62..2a07d7f 100644 --- a/gradio_demo/app-multicontrolnet.py +++ b/gradio_demo/app-multicontrolnet.py @@ -23,7 +23,7 @@ from huggingface_hub import hf_hub_download from insightface.app import FaceAnalysis from style_template import styles -from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline +from pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline from model_util import load_models_xl, get_torch_device, torch_gc from controlnet_util import openpose, get_depth_map, get_canny_image @@ -312,6 +312,7 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F seed, scheduler, enable_LCM, + enhance_face_region, progress=gr.Progress(track_tqdm=True), ): @@ -381,6 +382,15 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F width, height = face_kps.size + if enhance_face_region: + control_mask = np.zeros([height, width, 3]) + x1, y1, x2, y2 = face_info["bbox"] + x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2) + control_mask[y1:y2, x1:x2] = 255 + control_mask = Image.fromarray(control_mask.astype(np.uint8)) + else: + control_mask = None + if len(controlnet_selection) > 0: controlnet_scales = { "pose": pose_strength, @@ -414,6 +424,7 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F negative_prompt=negative_prompt, image_embeds=face_emb, image=control_images, + control_mask=control_mask, controlnet_conditioning_scale=control_scales, num_inference_steps=num_steps, guidance_scale=guidance_scale, @@ -588,6 +599,7 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F value="EulerDiscreteScheduler", ) randomize_seed = gr.Checkbox(label="Randomize seed", value=True) + enhance_face_region = gr.Checkbox(label="Enhance non-face region", value=True) with gr.Column(scale=1): gallery = gr.Image(label="Generated Images") @@ -623,6 +635,7 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F seed, scheduler, enable_LCM, + enhance_face_region, ], outputs=[gallery, usage_tips], ) diff --git a/gradio_demo/app.py b/gradio_demo/app.py index c063048..1105eb9 100644 --- a/gradio_demo/app.py +++ b/gradio_demo/app.py @@ -23,7 +23,7 @@ import insightface from insightface.app import FaceAnalysis from style_template import styles -from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline +from pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline from model_util import load_models_xl, get_torch_device, torch_gc import gradio as gr diff --git a/infer.py b/infer.py index eb72a46..500814f 100644 --- a/infer.py +++ b/infer.py @@ -7,7 +7,7 @@ from diffusers.utils import load_image from diffusers.models import ControlNetModel from insightface.app import FaceAnalysis -from pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline, draw_kps +from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline, draw_kps def resize_img(input_image, max_side=1280, min_side=1024, size=None, pad_to_max_side=False, mode=Image.BILINEAR, base_pixel_number=64):