Views
No views yet

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.SanaPipeline with 🧨diffusers[!IMPORTANT] Make sure to specifypipe.transformerto defaulttorch_dtypeandvariantaccording to Model Card.
1# run `pip install git+https://github.com/huggingface/diffusers` before use Sana in diffusers
2import torch
3from diffusers import SanaPipeline
4
5pipe = SanaPipeline.from_pretrained(
6 "Efficient-Large-Model/Sana_1600M_512px_diffusers",
7 variant="fp16",
8 torch_dtype=torch.float16,
9)
10pipe.to("cuda")
11
12pipe.vae.to(torch.bfloat16)
13pipe.text_encoder.to(torch.bfloat16)
14
15prompt = 'A cute 🐼 eating 🎋, ink drawing style'
16image = pipe(
17 prompt=prompt,
18 height=512,
19 width=512,
20 guidance_scale=4.5,
21 num_inference_steps=20,
22 generator=torch.Generator(device="cuda").manual_seed(42),
23)[0]
24
25image[0].save("sana.png")SanaPAGPipeline with 🧨diffusers1# run `pip install git+https://github.com/huggingface/diffusers` before use Sana in diffusers
2import torch
3from diffusers import SanaPAGPipeline
4
5pipe = SanaPAGPipeline.from_pretrained(
6 "Efficient-Large-Model/Sana_1600M_512px_diffusers",
7 variant="fp16",
8 torch_dtype=torch.float16,
9 pag_applied_layers="transformer_blocks.8",
10)
11pipe.to("cuda")
12
13pipe.text_encoder.to(torch.bfloat16)
14pipe.vae.to(torch.bfloat16)
15
16prompt = 'A cute 🐼 eating 🎋, ink drawing style'
17image = pipe(
18 prompt=prompt,
19 height=512,
20 width=512,
21 guidance_scale=5.0,
22 pag_scale=2.0,
23 num_inference_steps=20,
24 generator=torch.Generator(device="cuda").manual_seed(42),
25)[0]
26image[0].save('sana.png')