Views
No views yet


1import torch
2from PIL import Image
3from app.sana_controlnet_pipeline import SanaControlNetPipeline
4
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7pipe = SanaControlNetPipeline("configs/sana_controlnet_config/Sana_600M_img1024_controlnet.yaml")
8pipe.from_pretrained("hf://Efficient-Large-Model/Sana_600M_1024px_ControlNet_HED/checkpoints/Sana_600M_1024px_ControlNet_HED.pth")
9
10ref_image = Image.open("asset/controlnet/ref_images/A transparent sculpture of a duck made out of glass. The sculpture is in front of a painting of a la.jpg")
11prompt = "A transparent sculpture of a duck made out of glass. The sculpture is in front of a painting of a landscape."
12
13images = pipe(
14 prompt=prompt,
15 ref_image=ref_image,
16 guidance_scale=4.5,
17 num_inference_steps=10,
18 sketch_thickness=2,
19 generator=torch.Generator(device=device).manual_seed(0),
20)generative-models Github repository (https://github.com/NVlabs/Sana),
which is more suitable for both training and inference and for which most advanced diffusion sampler like Flow-DPM-Solver is integrated.
MIT Han-Lab provides free Sana inference.