Prgckwb commited on
Commit
c241116
1 Parent(s): 23c37e5

:tada: init

Browse files
Files changed (3) hide show
  1. app.py +28 -4
  2. assets/aeroplane.png +0 -0
  3. assets/dogcat.png +0 -0
app.py CHANGED
@@ -306,16 +306,40 @@ def inference(image: Image.Image, prompt: str, progress=gr.Progress(track_tqdm=T
306
 
307
 
308
  if __name__ == '__main__':
309
- ca_output = [gr.Image(type="pil", label="Attention Map") for _ in range(16)]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
 
311
  iface = gr.Interface(
312
  title="Stable Diffusion Attention Visualizer",
313
- description="",
314
  fn=inference,
315
  inputs=[
316
- gr.Image(type="pil", label="Input Image", width=512, height=512),
317
- gr.Textbox(label="Prompt", placeholder="Enter a prompt here..."),
318
  ],
319
  outputs=ca_output,
 
 
 
 
 
320
  )
 
321
  iface.launch()
 
306
 
307
 
308
  if __name__ == '__main__':
309
+ unet_mapping = [
310
+ "0: Down 64",
311
+ "1: Down 64",
312
+ "2: Down 32",
313
+ "3: Down 32",
314
+ "4: Down 16",
315
+ "5: Down 16",
316
+ "6: Mid 8",
317
+ "7: Up 16",
318
+ "8: Up 16",
319
+ "9: Up 16",
320
+ "10: Up 32",
321
+ "11: Up 32",
322
+ "12: Up 32",
323
+ "13: Up 64",
324
+ "14: Up 64",
325
+ "15: Up 64",
326
+ ]
327
+ ca_output = [gr.Image(type="pil", label=unet_mapping[i]) for i in range(16)]
328
 
329
  iface = gr.Interface(
330
  title="Stable Diffusion Attention Visualizer",
331
+ description="This is a visualizer for the attention maps of the Stable Diffusion model. ",
332
  fn=inference,
333
  inputs=[
334
+ gr.Image(type="pil", label="Input", width=512, height=512),
335
+ gr.Textbox(label="Prompt", placeholder="e.g.) A photo of dog...")
336
  ],
337
  outputs=ca_output,
338
+ cache_examples=True,
339
+ examples=[
340
+ [Image.open("assets/aeroplane.png"), "plane, background"],
341
+ [Image.open("assets/dogcat.png"), "a photo of dog and cat"],
342
+ ]
343
  )
344
+
345
  iface.launch()
assets/aeroplane.png ADDED
assets/dogcat.png ADDED