Spaces:
Runtime error
Runtime error
Commit
·
953809c
1
Parent(s):
dd97a63
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,16 +2,20 @@ import gradio as gr
|
|
| 2 |
from PIL import Image
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
from diffusers import
|
| 6 |
from free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
model_id = "stabilityai/stable-diffusion-2-1"
|
| 11 |
# model_id = "./stable-diffusion-2-1"
|
| 12 |
-
pip_2_1 =
|
| 13 |
pip_2_1 = pip_2_1.to("cuda")
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
prompt_prev = None
|
| 16 |
sd_options_prev = None
|
| 17 |
seed_prev = None
|
|
@@ -23,14 +27,14 @@ def infer(prompt, sd_options, seed, b1, b2, s1, s2):
|
|
| 23 |
global seed_prev
|
| 24 |
global sd_image_prev
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
pip = pip_2_1
|
| 34 |
|
| 35 |
run_baseline = False
|
| 36 |
if prompt != prompt_prev or sd_options != sd_options_prev or seed != seed_prev:
|
|
@@ -145,11 +149,10 @@ with block:
|
|
| 145 |
)
|
| 146 |
btn = gr.Button("Generate image", scale=0)
|
| 147 |
with gr.Row():
|
| 148 |
-
sd_options = gr.Dropdown(["SD2.1"], label="SD options", value="SD2.1", visible=
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
-
|
| 153 |
with gr.Group():
|
| 154 |
with gr.Row():
|
| 155 |
with gr.Accordion('FreeU Parameters (feel free to adjust these parameters based on your prompt): ', open=False):
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
from diffusers import DiffusionPipeline
|
| 6 |
from free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
model_id = "stabilityai/stable-diffusion-2-1"
|
| 11 |
# model_id = "./stable-diffusion-2-1"
|
| 12 |
+
pip_2_1 = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 13 |
pip_2_1 = pip_2_1.to("cuda")
|
| 14 |
|
| 15 |
+
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 16 |
+
pip_XL = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 17 |
+
pip_XL = pip_XL.to("cuda")
|
| 18 |
+
|
| 19 |
prompt_prev = None
|
| 20 |
sd_options_prev = None
|
| 21 |
seed_prev = None
|
|
|
|
| 27 |
global seed_prev
|
| 28 |
global sd_image_prev
|
| 29 |
|
| 30 |
+
if sd_options == 'SD2.1':
|
| 31 |
+
pip = pip_2_1
|
| 32 |
+
elif sd_options == 'SDXL':
|
| 33 |
+
pip = pip_XL
|
| 34 |
+
else:
|
| 35 |
+
pip = pip_2_1
|
| 36 |
|
| 37 |
+
# pip = pip_2_1
|
| 38 |
|
| 39 |
run_baseline = False
|
| 40 |
if prompt != prompt_prev or sd_options != sd_options_prev or seed != seed_prev:
|
|
|
|
| 149 |
)
|
| 150 |
btn = gr.Button("Generate image", scale=0)
|
| 151 |
with gr.Row():
|
| 152 |
+
sd_options = gr.Dropdown(["SD2.1", "SDXL"], label="SD options", value="SD2.1", visible=True)
|
| 153 |
|
| 154 |
|
| 155 |
|
|
|
|
| 156 |
with gr.Group():
|
| 157 |
with gr.Row():
|
| 158 |
with gr.Accordion('FreeU Parameters (feel free to adjust these parameters based on your prompt): ', open=False):
|