Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add controlnet-1.5-face #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SabatinoMasala
Copy link
Contributor

I added a template for CrucibleAI/ControlNetMediaPipeFace.

To test, please add the following file to the images folder and call it face_annotation.png:
https://huggingface.co/CrucibleAI/ControlNetMediaPipeFace/resolve/main/samples_laion_face_dataset/happy_annotation.png

Go into the controlnet-1.5-face folder, add some weights and run:

make download
make test_face

This will output the controlled image like so:
output 0

Control image for reference:
face_annotation

Known limitations:

The template currently does not preprocess images and expects a preprocessed image as an input. We could implement https://huggingface.co/CrucibleAI/ControlNetMediaPipeFace/blob/main/tool_generate_face_poses.py to preprocess the images.


ControlNetModel.from_pretrained(
settings.CONTROLNET_MODEL,
subfolder="diffusion_sd15",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the sd15 variant instead of the default 21 variant

Comment on lines +60 to +66
controlnet = ControlNetModel.from_pretrained(
settings.CONTROLNET_MODEL,
subfolder="diffusion_sd15",
torch_dtype=torch.float16,
cache_dir=settings.MODEL_CACHE,
local_files_only=True,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Load the sd15 variant for ControlNetMediaPipeFace

Comment on lines +121 to +126
def process_control(self, control_image):
if control_image is None:
return None

# TODO do some actual pre-processing instead of returning the already pre-processed control image
return control_image
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently just returns the already preprocessed control image. We could add some actual preprocessing here, eg. by implementing https://huggingface.co/CrucibleAI/ControlNetMediaPipeFace/blob/main/tool_generate_face_poses.py

@@ -0,0 +1,4 @@
MODEL_CACHE = "diffusers-cache"
SAFETY_MODEL_ID = "CompVis/stable-diffusion-safety-checker"
CONTROLNET_MODEL = "CrucibleAI/ControlNetMediaPipeFace"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SabatinoMasala
Copy link
Contributor Author

Confirmed working on replicate, see this template

image

@anotherjesse
Copy link
Owner

@SabatinoMasala what do you think about the idea of having a separate control_image_processed (or another input name) - that lets you know you can skip the processing step.

I can see it being useful for other controlnets as well

@anotherjesse
Copy link
Owner

I wrote this up the other day: #12

@SabatinoMasala
Copy link
Contributor Author

@anotherjesse, a separate control_image_processed makes total sense indeed!

@SabatinoMasala
Copy link
Contributor Author

In the following commit I introduced control_image_processed on this new template
e60e70e

@SabatinoMasala
Copy link
Contributor Author

With the introduction of ControlNet 1.1, Openpose face is included. We can probably consider this PR irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants