linoyts HF staff commited on
Commit
bcb24fd
·
verified ·
1 Parent(s): bca64d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -27
app.py CHANGED
@@ -220,47 +220,66 @@ bags_min = torch.min(proj@bags[0]/(torch.norm(bags))**2).item()
220
 
221
 
222
 
223
- css = ''
224
- with gr.Blocks(css=css) as demo:
225
- gr.Markdown("# <em>weights2weights</em> Demo")
226
- gr.Markdown("Demo for the [h94/IP-Adapter-FaceID model](https://huggingface.co/h94/IP-Adapter-FaceID) - Generate AI images with your own face - Non-commercial license")
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- prompt = gr.Textbox(label="Prompt",
234
- info="Make sure to include 'sks person'" ,
235
- placeholder="sks person",
236
- value="sks person")
237
- negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, cartoon", value="low quality, blurry, unfinished, cartoon")
238
- seed = gr.Number(value=5, label="Seed", interactive=True)
239
- cfg = gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
240
- steps = gr.Slider(label="Inference Steps", value=50, step=1, minimum=0, maximum=100, interactive=True)
241
- injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
242
-
243
 
244
- with gr.Row():
245
- a1 = gr.Slider(label="Young", value=0, step=1, minimum=-1000000, maximum=1000000, interactive=True)
246
- a2 = gr.Slider(label="Pointy Nose", value=0, step=1, minimum=-1000000, maximum=1000000, interactive=True)
247
- a3 = gr.Slider(label="Undereye Bags", value=0, step=1, minimum=-1000000, maximum=1000000, interactive=True)
 
 
 
248
 
249
 
250
- submit = gr.Button("Submit")
 
251
 
252
- with gr.Column():
253
- gallery2 = gr.Gallery(label="Identity from Edited Model")
254
 
255
 
256
 
257
 
258
- sample.click(fn=sample_then_run, outputs=gallery1)
259
 
260
-
261
- submit.click(fn=edit_inference,
262
- inputs=[prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3],
263
- outputs=gallery2)
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