Skip to content

"FreeU: Free Lunch in Diffusion U-Net" for Huggingface Diffusers

License

Notifications You must be signed in to change notification settings

camenduru/FreeU_Diffusers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

"FreeU: Free Lunch in Diffusion U-Net" for Diffusers

The offical code https://github.com/ChenyangSi/FreeU

Usage

from diffusers import StableDiffusionPipeline
import torch
from .free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

# -------- freeu block registration
register_free_upblock2d(pipe, b1=1.2, b2=1.4, s1=0.9, s2=0.2)
register_free_crossattn_upblock2d(pipe, b1=1.2, b2=1.4, s1=0.9, s2=0.2)
# -------- freeu block registration

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]  
    
image.save("astronaut_rides_horse.png")

Note that it is supported and tested on diffusers v0.19.3. If you are using the latest diffusers, it is recommended to use the corresponding branch, but it has not been tested.

About

"FreeU: Free Lunch in Diffusion U-Net" for Huggingface Diffusers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%