Instructions to use Efficient-Large-Model/Sana_1600M_512px with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Sana
How to use Efficient-Large-Model/Sana_1600M_512px with Sana:
# Load the model and infer image from text import torch from app.sana_pipeline import SanaPipeline from torchvision.utils import save_image sana = SanaPipeline("configs/sana_config/1024ms/Sana_1600M_img1024.yaml") sana.from_pretrained("hf://Efficient-Large-Model/Sana_1600M_512px") image = sana( prompt='a cyberpunk cat with a neon sign that says "Sana"', height=1024, width=1024, guidance_scale=5.0, pag_guidance_scale=2.0, num_inference_steps=18, ) - Notebooks
- Google Colab
- Kaggle
not run
not run nnever on colab t4
import torch
from app.sana_pipeline import SanaPipeline
from torchvision.utils import save_image
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
generator = torch.Generator(device=device).manual_seed(42)
sana = SanaPipeline("/content/Sana/configs/sana_config/512ms/Sana_600M_img512.yaml")
sana.from_pretrained("https://huggingface.co/Efficient-Large-Model/Sana_1600M_512px/blob/main/checkpoints/Sana_1600M_512px.pth")
prompt = 'a cyberpunk cat with a neon sign that says "Sana"'
image = sana(
prompt=prompt,
height=128,
width=128,
guidance_scale=1.0,
pag_guidance_scale=1.0,
num_inference_steps=5,
generator=generator,
)
save_image(image, '/content/sana.png', nrow=1, normalize=True, value_range=(-1, 1))
2024-11-23 07:01:20 - [Sana] - INFO - Sampler flow_dpm-solver, flow_shift: 1.0
2024-11-23 07:01:20 - [Sana] - INFO - Inference with torch.float16, PAG guidance layer: [14]
[DC-AE] Loading model from mit-han-lab/dc-ae-f32c32-sana-1.0
Loading checkpoint shards: 100%
2/2 [00:01<00:00, 1.87it/s]
2024-11-23 07:02:03 - [Sana] - WARNING - use pe: False, position embed interpolation: 1.0, base size: 16
2024-11-23 07:02:03 - [Sana] - WARNING - attention type: linear; ffn type: glumbconv; autocast linear attn: False
Your session crashed after using all available RAM
Sana-0.6B ?????????????????
| sana = SanaPipeline("/content/Sana/configs/sana_config/512ms/Sana_600M_img512.yaml")
| sana.from_pretrained("https://huggingface.co/Efficient-Large-Model/Sana_1600M_512px/blob/main/checkpoints/Sana_1600M_512px.pth")
Why are you using 600M config file and loading 1600M checkpoints?