Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -220,47 +220,66 @@ bags_min = torch.min(proj@bags[0]/(torch.norm(bags))**2).item()
|
|
220 |
|
221 |
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
with gr.Row():
|
228 |
with gr.Column():
|
229 |
-
sample = gr.Button("Sample New Model")
|
230 |
gallery1 = gr.Gallery(label="Identity from Sampled Model")
|
|
|
|
|
|
|
231 |
|
|
|
232 |
with gr.Column():
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
248 |
|
249 |
|
250 |
-
|
|
|
251 |
|
252 |
-
with gr.Column():
|
253 |
-
gallery2 = gr.Gallery(label="Identity from Edited Model")
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
-
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
|
265 |
|
266 |
|
|
|
220 |
|
221 |
|
222 |
|
223 |
+
intro = """
|
224 |
+
<div style="display: flex;align-items: center;justify-content: center">
|
225 |
+
<h1 style="margin-left: 12px;text-align: center;margin-bottom: 7px;display: inline-block">weights2weights</h1>
|
226 |
+
<h3 style="display: inline-block;margin-left: 10px;margin-top: 6px;font-weight: 500">Interpreting the Weight Space of Customized Diffusion Models</h3>
|
227 |
+
</div>
|
228 |
+
<p style="font-size: 0.95rem;margin: 0rem;line-height: 1.2em;margin-top:1em;display: inline-block">
|
229 |
+
<a href="https://snap-research.github.io/weights2weights/" target="_blank">project page</a> | <a href="https://arxiv.org/abs/2406.09413" target="_blank">paper</a>
|
230 |
+
|
|
231 |
+
<a href="https://huggingface.co/spaces/Snapchat/w2w-demo?duplicate=true" target="_blank" style="
|
232 |
+
display: inline-block;
|
233 |
+
">
|
234 |
+
<img style="margin-top: -1em;margin-bottom: 0em;position: absolute;" src="https://bit.ly/3CWLGkA" alt="Duplicate Space"></a>
|
235 |
+
</p>
|
236 |
+
"""
|
237 |
+
|
238 |
+
with gr.Blocks(css="style.css") as demo:
|
239 |
+
gr.HTML(intro)
|
240 |
with gr.Row():
|
241 |
with gr.Column():
|
|
|
242 |
gallery1 = gr.Gallery(label="Identity from Sampled Model")
|
243 |
+
sample = gr.Button("Sample New Model")
|
244 |
+
gallery2 = gr.Gallery(label="Identity from Edited Model")
|
245 |
+
|
246 |
|
247 |
+
with gr.Row():
|
248 |
with gr.Column():
|
249 |
+
prompt = gr.Textbox(label="Prompt",
|
250 |
+
info="Make sure to include 'sks person'" ,
|
251 |
+
placeholder="sks person",
|
252 |
+
value="sks person")
|
253 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, cartoon", value="low quality, blurry, unfinished, cartoon")
|
254 |
+
with gr.Row():
|
255 |
+
a1 = gr.Slider(label="Young", value=0, step=1, minimum=-1000000, maximum=1000000, interactive=True)
|
256 |
+
a2 = gr.Slider(label="Pointy Nose", value=0, step=1, minimum=-1000000, maximum=1000000, interactive=True)
|
257 |
+
a3 = gr.Slider(label="Undereye Bags", value=0, step=1, minimum=-1000000, maximum=1000000, interactive=True)
|
|
|
258 |
|
259 |
+
|
260 |
+
with gr.Accordion("Advanced Options", open=False):
|
261 |
+
with gr.Column():
|
262 |
+
seed = gr.Number(value=5, label="Seed", interactive=True)
|
263 |
+
cfg = gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
|
264 |
+
steps = gr.Slider(label="Inference Steps", value=50, step=1, minimum=0, maximum=100, interactive=True)
|
265 |
+
injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
|
266 |
|
267 |
|
268 |
+
|
269 |
+
submit = gr.Button("Submit")
|
270 |
|
271 |
+
#with gr.Column():
|
272 |
+
#gallery2 = gr.Gallery(label="Identity from Edited Model")
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
+
sample.click(fn=sample_then_run, outputs=gallery1)
|
278 |
|
279 |
+
|
280 |
+
submit.click(fn=edit_inference,
|
281 |
+
inputs=[prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3],
|
282 |
+
outputs=gallery2)
|
283 |
|
284 |
|
285 |
|