Skip to content

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

Closed

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.

Activity

  1. a-r-r-o-w commented on Feb 23, 2025

    @a-r-r-o-w
    Contributor

    cc @DN6

  2. yiyixuxu commented on Feb 24, 2025

    @yiyixuxu
    Collaborator

    if anyone from the community can take up this, that would be great!
    we'd happy to give guidance/help with the PR

  3. added
    roadmap
    on Feb 25, 2025
  4. Aravind-11 commented on Mar 1, 2025

    @Aravind-11

    Hi, is this issue still open? Can I work on this ?

  5. nitinmukesh commented on Mar 1, 2025

    @nitinmukesh
    Author

    @Aravind-11

    I have not seen open PR for this, so please if you can add work on this will be helpful.

  6. yiyixuxu commented on Mar 4, 2025

    @yiyixuxu
    Collaborator

    feel free to test under #10947!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good second issuecontributions-welcomehelp wantedroadmap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions