Spaces:
Runtime error
Runtime error
Commit
·
fac7910
1
Parent(s):
b107b62
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,20 +19,22 @@ model_id = "CompVis/stable-diffusion-v1-4"
|
|
| 19 |
# register_free_crossattn_upblock2d(pip_freeu, b1=1.2, b2=1.4, s1=0.9, s2=0.2)
|
| 20 |
# # -------- freeu block registration
|
| 21 |
|
| 22 |
-
def infer(prompt,
|
| 23 |
-
|
| 24 |
-
# # -------- freeu block registration
|
| 25 |
-
# register_free_upblock2d(pip_freeu, b1=b1, b2=b2, s1=s1, s2=s1)
|
| 26 |
-
# register_free_crossattn_upblock2d(pip_freeu, b1=b1, b2=b2, s1=s1, s2=s1)
|
| 27 |
-
# # -------- freeu block registration
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
torch.manual_seed(seed)
|
| 30 |
print("Generating SD:")
|
| 31 |
-
sd_image =
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
torch.manual_seed(seed)
|
| 34 |
print("Generating FreeU:")
|
| 35 |
-
freeu_image =
|
| 36 |
|
| 37 |
# First SD, then freeu
|
| 38 |
images = [sd_image, freeu_image]
|
|
@@ -114,20 +116,20 @@ with block:
|
|
| 114 |
else:
|
| 115 |
model_id = "CompVis/stable-diffusion-v1-4"
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
pip_freeu = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 121 |
-
pip_freeu = pip_freeu.to("cuda")
|
| 122 |
|
| 123 |
with gr.Row():
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
| 131 |
seed = gr.Slider(label='seed',
|
| 132 |
minimum=0,
|
| 133 |
maximum=1000,
|
|
@@ -162,15 +164,14 @@ with block:
|
|
| 162 |
|
| 163 |
with gr.Row():
|
| 164 |
with gr.Group():
|
| 165 |
-
btn = gr.Button("Generate image", scale=0)
|
| 166 |
with gr.Row():
|
| 167 |
with gr.Column(min_width=256) as c1:
|
| 168 |
image_1 = gr.Image(interactive=False)
|
| 169 |
image_1_label = gr.Markdown("SD")
|
| 170 |
|
| 171 |
with gr.Group():
|
| 172 |
-
btn = gr.Button("Generate image", scale=0)
|
| 173 |
-
|
| 174 |
with gr.Row():
|
| 175 |
with gr.Column(min_width=256) as c2:
|
| 176 |
image_2 = gr.Image(interactive=False)
|
|
|
|
| 19 |
# register_free_crossattn_upblock2d(pip_freeu, b1=1.2, b2=1.4, s1=0.9, s2=0.2)
|
| 20 |
# # -------- freeu block registration
|
| 21 |
|
| 22 |
+
def infer(prompt, pip, seed, b1, b2, s1, s2):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
|
| 25 |
+
# register_free_upblock2d(pip, b1=1.0, b2=1.0, s1=1.0, s2=1.0)
|
| 26 |
+
# register_free_crossattn_upblock2d(pip, b1=1.0, b2=1.0, s1=1.0, s2=1.0)
|
| 27 |
+
|
| 28 |
torch.manual_seed(seed)
|
| 29 |
print("Generating SD:")
|
| 30 |
+
sd_image = pip(prompt).images[0]
|
| 31 |
+
|
| 32 |
+
# register_free_upblock2d(pip, b1=b1, b2=b2, s1=s1, s2=s1)
|
| 33 |
+
# register_free_crossattn_upblock2d(pip, b1=b1, b2=b2, s1=s1, s2=s1)
|
| 34 |
|
| 35 |
torch.manual_seed(seed)
|
| 36 |
print("Generating FreeU:")
|
| 37 |
+
freeu_image = pip(prompt).images[0]
|
| 38 |
|
| 39 |
# First SD, then freeu
|
| 40 |
images = [sd_image, freeu_image]
|
|
|
|
| 116 |
else:
|
| 117 |
model_id = "CompVis/stable-diffusion-v1-4"
|
| 118 |
|
| 119 |
+
pip = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 120 |
+
pip = pip_sd.to("cuda")
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
with gr.Row():
|
| 123 |
+
with gr.Column():
|
| 124 |
+
text = gr.Textbox(
|
| 125 |
+
label="Enter your prompt",
|
| 126 |
+
show_label=False,
|
| 127 |
+
max_lines=1,
|
| 128 |
+
placeholder="Enter your prompt",
|
| 129 |
+
container=False,
|
| 130 |
+
)
|
| 131 |
+
btn = gr.Button("Generate image", scale=0)
|
| 132 |
+
|
| 133 |
seed = gr.Slider(label='seed',
|
| 134 |
minimum=0,
|
| 135 |
maximum=1000,
|
|
|
|
| 164 |
|
| 165 |
with gr.Row():
|
| 166 |
with gr.Group():
|
| 167 |
+
# btn = gr.Button("Generate image", scale=0)
|
| 168 |
with gr.Row():
|
| 169 |
with gr.Column(min_width=256) as c1:
|
| 170 |
image_1 = gr.Image(interactive=False)
|
| 171 |
image_1_label = gr.Markdown("SD")
|
| 172 |
|
| 173 |
with gr.Group():
|
| 174 |
+
# btn = gr.Button("Generate image", scale=0)
|
|
|
|
| 175 |
with gr.Row():
|
| 176 |
with gr.Column(min_width=256) as c2:
|
| 177 |
image_2 = gr.Image(interactive=False)
|