Skip to content

[Feature request] Please add from_single_file support in SanaTransformer2DModel to support first Sana Apache licensed model #10872

Closed
@nitinmukesh

Description

@nitinmukesh

Is your feature request related to a problem? Please describe.
We all know Sana model is very good but unfortunately the LICENSE is restrictive.
Recently a Sana finetuned model is released under Apache LICENSE. Unfortunately SanaTransformer2DModel does not support from_single_file to use it

Describe the solution you'd like.

import torch
from diffusers import SanaPipeline
from diffusers import SanaTransformer2DModel
model_path = "Efficient-Large-Model/Sana_1600M_1024px_MultiLing"
dtype = torch.float16
transformer = SanaTransformer2DModel.from_single_file (
	"Swarmeta-AI/Twig-v0-alpha/Twig-v0-alpha-1.6B-2048x-fp16.pth",
	torch_dtype=dtype,
)
pipe = SanaPipeline.from_pretrained(
	pretrained_model_name_or_path=model_path,
	transformer=transformer,
	torch_dtype=dtype,
	use_safetensors=True,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()
pipe.enable_vae_tiling()
inference_params = {
	"prompt": "rose flower",
	"negative_prompt": "",
	"height": 1024,
	"width": 1024,
	"guidance_scale": 4.0,
	"num_inference_steps": 20,

}
image = pipe(**inference_params).images[0]
image.save("sana.png")
(venv) C:\aiOWN\diffuser_webui>python sana_apache.py
Traceback (most recent call last):
  File "C:\aiOWN\diffuser_webui\sana_apache.py", line 6, in <module>
    transformer = SanaTransformer2DModel.from_single_file (
AttributeError: type object 'SanaTransformer2DModel' has no attribute 'from_single_file'

Describe alternatives you've considered.
No alternatives available as far as I know

Additional context.
N.A.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions