# ***ControlNet Head Mesh SDXL*** # ControlNet Example(Conditioned on 3D Head Mesh) ![images_0)](./pncc_example.jpg) # Head Mesh Processor Install pip install git+https://github.com/KupynOrest/head_detector.git # Code to Use Tile blur ```python from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL from diffusers import EulerAncestralDiscreteScheduler from PIL import Image import torch import numpy as np import cv2 from head_detector import HeadDetector detector = HeadDetector() controlnet_conditioning_scale = 1.0 prompt = "your prompt, the longer the better, you can describe it as detail as possible" negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality' eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler") controlnet = ControlNetModel.from_pretrained( "okupyn/head-mesh-controlnet-xl", torch_dtype=torch.float16 ) # when test with other base model, you need to change the vae also. vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16) pipe = StableDiffusionXLControlNetPipeline.from_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, vae=vae, safety_checker=None, torch_dtype=torch.float16, scheduler=eulera_scheduler, ) controlnet_img = detector("your original image path").get_pncc() controlnet_img = Image.fromarray(controlnet_img) images = pipe( prompt, negative_prompt=negative_prompt, image=controlnet_img, controlnet_conditioning_scale=controlnet_conditioning_scale, num_inference_steps=30, ).images images[0].save(f"your image save path") ``` --- license: cc-by-nc-4.0 library_name: diffusers ---