Prgckwb commited on
Commit
3c9c988
1 Parent(s): 038350c

:tada: init

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -188,8 +188,9 @@ unet.set_attn_processor(
188
 
189
 
190
  @torch.inference_mode()
191
- def inference(image: Image.Image, prompt: str, progress=gr.Progress(track_tqdm=True)):
192
  progress(0, "Initializing...")
 
193
  image = image.convert("RGB").resize((512, 512))
194
  image = to_tensor(image).unsqueeze(0).to(device)
195
 
@@ -331,14 +332,14 @@ if __name__ == '__main__':
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
 
 
188
 
189
 
190
  @torch.inference_mode()
191
+ def inference(image_path: str, prompt: str, progress=gr.Progress(track_tqdm=False)):
192
  progress(0, "Initializing...")
193
+ image = Image.open(image_path)
194
  image = image.convert("RGB").resize((512, 512))
195
  image = to_tensor(image).unsqueeze(0).to(device)
196
 
 
332
  description="This is a visualizer for the attention maps of the Stable Diffusion model. ",
333
  fn=inference,
334
  inputs=[
335
+ gr.Image(type="filepath", label="Input", width=512, height=512),
336
  gr.Textbox(label="Prompt", placeholder="e.g.) A photo of dog...")
337
  ],
338
  outputs=ca_output,
339
  cache_examples=True,
340
  examples=[
341
+ ["assets/aeroplane.png", "plane background"],
342
+ ["assets/dogcat.png", "a photo of dog and cat"],
343
  ]
344
  )
345