Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nitinmukesh opened this issue Feb 23, 2025 · 4 comments
Labels
contributions-welcome Good second issue help wanted Extra attention is needed roadmap Add to current release roadmap

Comments

@nitinmukesh
Copy link

nitinmukesh commented Feb 23, 2025

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.

@a-r-r-o-w
Copy link
Member

cc @DN6

@yiyixuxu
Copy link
Collaborator

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

@yiyixuxu yiyixuxu added the roadmap Add to current release roadmap label Feb 25, 2025
@Aravind-11
Copy link

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

@nitinmukesh
Copy link
Author

@Aravind-11

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions-welcome Good second issue help wanted Extra attention is needed roadmap Add to current release roadmap
Projects
Status: No status
Development

No branches or pull requests

4 participants