Skip to content

Commit

Permalink
Merge pull request #4 from neurowelt/master
Browse files Browse the repository at this point in the history
Support for `UNet3DConditionModel`
  • Loading branch information
lyn-rgb authored Sep 28, 2023
2 parents 70ec91d + 951cf56 commit 32de13a
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# MacOS
# =====
.DS_Store
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
The offical code https://github.com/ChenyangSi/FreeU

## Usage

### Image Pipelines

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

model_id = "runwayml/stable-diffusion-v1-5"
Expand All @@ -23,5 +26,32 @@ image = pipe(prompt).images[0]
image.save("astronaut_rides_horse.png")
```

### Video Pipelines

```python
import torch
from diffusers import TextToVideoSDPipeline
from diffusers.utils import export_to_video
from .free_lunch_utils import register_free_upblock3d, register_free_crossattn_upblock3d

model_id = "cerspense/zeroscope_v2_576w"
pipe = TextToVideoSDPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

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

prompt = "an astronaut riding a horse on mars"
video_frames = pipe(prompt, height=320, width=576, num_frames=30).frames

export_to_video(video_frames, "astronaut_rides_horse.mp4")
```

#### 28/09/23
Current version was successfully ran on diffusers v0.21.2.

#### 26/09/23
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.
If you are using the latest diffusers, it is recommended to use the corresponding branch, but it has not been tested.
6 changes: 5 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from .free_lunch_utils import register_upblock2d, register_free_upblock2d, register_crossattn_upblock2d, register_free_crossattn_upblock2d
from .free_lunch_utils import (
register_upblock2d, register_free_upblock2d,
register_crossattn_upblock2d, register_free_crossattn_upblock2d,
register_upblock3d, register_free_upblock3d
)
Loading

0 comments on commit 32de13a

Please sign in to comment.