File size: 1,981 Bytes
018348e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# demo & simple test
def main():
from diffusers.utils import load_image
pipe = StableDiffusionMultiControlNetPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", safety_checker=None, torch_dtype=torch.float16
).to("cuda")
pipe.enable_xformers_memory_efficient_attention()
controlnet_canny = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", torch_dtype=torch.float16).to(
"cuda"
)
controlnet_pose = ControlNetModel.from_pretrained(
"lllyasviel/sd-controlnet-openpose", torch_dtype=torch.float16
).to("cuda")
canny_left = load_image("https://huggingface.co/takuma104/controlnet_dev/resolve/main/vermeer_left.png")
canny_right = load_image("https://huggingface.co/takuma104/controlnet_dev/resolve/main/vermeer_right.png")
pose_right = load_image("https://huggingface.co/takuma104/controlnet_dev/resolve/main/pose_right.png")
image = pipe(
prompt="best quality, extremely detailed",
negative_prompt="monochrome, lowres, bad anatomy, worst quality, low quality",
processors=[
ControlNetProcessor(controlnet_canny, canny_left),
ControlNetProcessor(controlnet_canny, canny_right),
],
generator=torch.Generator(device="cpu").manual_seed(0),
num_inference_steps=30,
width=512,
height=512,
).images[0]
image.save("/tmp/canny_left_right.png")
image = pipe(
prompt="best quality, extremely detailed",
negative_prompt="monochrome, lowres, bad anatomy, worst quality, low quality",
processors=[
ControlNetProcessor(controlnet_canny, canny_left),
ControlNetProcessor(controlnet_pose, pose_right),
],
generator=torch.Generator(device="cpu").manual_seed(0),
num_inference_steps=30,
width=512,
height=512,
).images[0]
image.save("/tmp/canny_left_pose_right.png")
if __name__ == "__main__":
main() |