Spaces:
Runtime error
Runtime error
Commit
·
3e7f1a1
1
Parent(s):
b23c75e
Update app.py
Browse files
app.py
CHANGED
@@ -104,55 +104,50 @@ with block:
|
|
104 |
)
|
105 |
btn = gr.Button("Generate image", scale=0)
|
106 |
|
107 |
-
#
|
108 |
-
|
109 |
-
#
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
#
|
124 |
-
|
125 |
-
|
126 |
-
#
|
127 |
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
# minimum=0,
|
152 |
-
# maximum=1,
|
153 |
-
# step=0.1,
|
154 |
-
# value=1)
|
155 |
-
|
156 |
with gr.Row():
|
157 |
with gr.Column(min_width=256) as c1:
|
158 |
image_1 = gr.Image(interactive=False)
|
@@ -162,11 +157,11 @@ with block:
|
|
162 |
image_2_label = gr.Markdown("FreeU")
|
163 |
|
164 |
|
165 |
-
ex = gr.Examples(examples=examples, fn=infer, inputs=[text], outputs=[image_1, image_2], cache_examples=False)
|
166 |
ex.dataset.headers = [""]
|
167 |
|
168 |
# text.submit(infer, inputs=[text, pip_sd, pip_freeu], outputs=[image_1, image_2])
|
169 |
# btn.click(infer, inputs=[text, pip_sd, pip_freeu], outputs=[image_1, image_2])
|
170 |
|
171 |
-
|
172 |
-
block.queue(default_enabled=False).launch(share=False)
|
|
|
104 |
)
|
105 |
btn = gr.Button("Generate image", scale=0)
|
106 |
|
107 |
+
# sd_options = gr.Dropdown(options, label="SD options")
|
108 |
+
sd_options = gr.Dropdown(options, value='SD1.4', label="SD options")
|
109 |
+
# model_id = "CompVis/stable-diffusion-v1-4"
|
110 |
|
111 |
+
if sd_options == 'SD1.4':
|
112 |
+
model_id = "CompVis/stable-diffusion-v1-4"
|
113 |
+
elif sd_options == 'SD1.5':
|
114 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
115 |
+
elif sd_options == 'SD2.1':
|
116 |
+
model_id = "stabilityai/stable-diffusion-2-1"
|
117 |
|
118 |
+
pip_sd = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
119 |
+
pip_sd = pip_sd.to("cuda")
|
120 |
+
|
121 |
+
pip_freeu = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
122 |
+
pip_freeu = pip_freeu.to("cuda")
|
123 |
+
# -------- freeu block registration
|
124 |
+
register_free_upblock2d(pipe, b1=1.2, b2=1.4, s1=0.9, s2=0.2)
|
125 |
+
register_free_crossattn_upblock2d(pipe, b1=1.2, b2=1.4, s1=0.9, s2=0.2)
|
126 |
+
# -------- freeu block registration
|
127 |
|
128 |
+
with gr.Accordion('FreeU Parameters', open=False):
|
129 |
|
130 |
+
b1 = gr.Slider(label='b1: backbone factor of the first stage block of decoder',
|
131 |
+
minimum=1,
|
132 |
+
maximum=1.6,
|
133 |
+
step=0.1,
|
134 |
+
value=1)
|
135 |
+
b2 = gr.Slider(label='b2: backbone factor of the second stage block of decoder',
|
136 |
+
minimum=1,
|
137 |
+
maximum=1.6,
|
138 |
+
step=0.1,
|
139 |
+
value=1)
|
140 |
+
s1 = gr.Slider(label='s1: skip factor of the first stage block of decoder',
|
141 |
+
minimum=0,
|
142 |
+
maximum=1,
|
143 |
+
step=0.1,
|
144 |
+
value=1)
|
145 |
+
s2 = gr.Slider(label='s2: skip factor of the second stage block of decoder',
|
146 |
+
minimum=0,
|
147 |
+
maximum=1,
|
148 |
+
step=0.1,
|
149 |
+
value=1)
|
150 |
+
|
|
|
|
|
|
|
|
|
|
|
151 |
with gr.Row():
|
152 |
with gr.Column(min_width=256) as c1:
|
153 |
image_1 = gr.Image(interactive=False)
|
|
|
157 |
image_2_label = gr.Markdown("FreeU")
|
158 |
|
159 |
|
160 |
+
ex = gr.Examples(examples=examples, fn=infer, inputs=[text, pip_sd, pip_freeu], outputs=[image_1, image_2], cache_examples=False)
|
161 |
ex.dataset.headers = [""]
|
162 |
|
163 |
# text.submit(infer, inputs=[text, pip_sd, pip_freeu], outputs=[image_1, image_2])
|
164 |
# btn.click(infer, inputs=[text, pip_sd, pip_freeu], outputs=[image_1, image_2])
|
165 |
|
166 |
+
block.launch()
|
167 |
+
# block.queue(default_enabled=False).launch(share=False)
|