Views
No views yet
| Input | Face Detection | Output |
|---|---|---|
f_thick = 2
f_rad = 1
right_iris_draw = DrawingSpec(color=(10, 200, 250), thickness=f_thick, circle_radius=f_rad)
right_eye_draw = DrawingSpec(color=(10, 200, 180), thickness=f_thick, circle_radius=f_rad)
right_eyebrow_draw = DrawingSpec(color=(10, 220, 180), thickness=f_thick, circle_radius=f_rad)
left_iris_draw = DrawingSpec(color=(250, 200, 10), thickness=f_thick, circle_radius=f_rad)
left_eye_draw = DrawingSpec(color=(180, 200, 10), thickness=f_thick, circle_radius=f_rad)
left_eyebrow_draw = DrawingSpec(color=(180, 220, 10), thickness=f_thick, circle_radius=f_rad)
mouth_draw = DrawingSpec(color=(10, 180, 10), thickness=f_thick, circle_radius=f_rad)
head_draw = DrawingSpec(color=(10, 200, 10), thickness=f_thick, circle_radius=f_rad)
iris_landmark_spec = {468: right_iris_draw, 473: left_iris_draw}draw_pupils which modifies some functionality from MediaPipe. It exists as a stopgap until some pending changes are merged.train_laion_face.py, laion_face_dataset.py, and other .py files should sit adjacent to tutorial_train.py and tutorial_train_sd21.py. We are assuming a checkout of the ControlNet repo at 0acb7e5, but there is no direct dependency on the repository.1python tool_add_control.py ./models/v1-5-pruned-emaonly.ckpt ./models/controlnet_sd15_laion_face.ckpt
2python ./train_laion_face_sd15.pygradio_face2image.py. Update the following two lines to point them to your trained model.model = create_model('./models/cldm_v21.yaml').cpu() # If you fine-tune on SD2.1 base, this does not need to change.
model.load_state_dict(load_state_dict('./models/control_sd21_openpose.pth', location='cuda'))subfolder="diffusion_sd15" into the from_pretrained arguments. A v1.5 half-precision variant is provided but untested.diffusers and related packages:$ pip install diffusers transformers accelerate1from PIL import Image
2import numpy as np
3import torch
4from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
5from diffusers.utils import load_image
6
7image = load_image(
8 "https://huggingface.co/CrucibleAI/ControlNetMediaPipeFace/resolve/main/samples_laion_face_dataset/family_annotation.png"
9)
10
11# Stable Diffusion 2.1-base:
12controlnet = ControlNetModel.from_pretrained("CrucibleAI/ControlNetMediaPipeFace", torch_dtype=torch.float16, variant="fp16")
13pipe = StableDiffusionControlNetPipeline.from_pretrained(
14 "stabilityai/stable-diffusion-2-1-base", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16
15)
16# OR
17# Stable Diffusion 1.5:
18controlnet = ControlNetModel.from_pretrained("CrucibleAI/ControlNetMediaPipeFace", subfolder="diffusion_sd15")
19pipe = StableDiffusionControlNetPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", controlnet=controlnet, safety_checker=None)
20
21pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
22
23# Remove if you do not have xformers installed
24# see https://huggingface.co/docs/diffusers/v0.13.0/en/optimization/xformers#installing-xformers
25# for installation instructions
26pipe.enable_xformers_memory_efficient_attention()
27pipe.enable_model_cpu_offload()
28
29image = pipe("a happy family at a dentist advertisement", image=image, num_inference_steps=30).images[0]
30image.save('./images.png')@misc{zhang2023adding,
title={Adding Conditional Control to Text-to-Image Diffusion Models},
author={Lvmin Zhang and Maneesh Agrawala},
year={2023},
eprint={2302.05543},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
@misc{rombach2021highresolution,
title={High-Resolution Image Synthesis with Latent Diffusion Models},
author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
year={2021},
eprint={2112.10752},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
@misc{schuhmann2022laion5b,
title={LAION-5B: An open large-scale dataset for training next generation image-text models},
author={Christoph Schuhmann and Romain Beaumont and Richard Vencu and Cade Gordon and Ross Wightman and Mehdi Cherti and Theo Coombes and Aarush Katta and Clayton Mullis and Mitchell Wortsman and Patrick Schramowski and Srivatsa Kundurthy and Katherine Crowson and Ludwig Schmidt and Robert Kaczmarczyk and Jenia Jitsev},
year={2022},
eprint={2210.08402},
archivePrefix={arXiv},
primaryClass={cs.CV}
}