Fawaz commited on
Commit
1401821
·
1 Parent(s): a3c1d07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -191,7 +191,8 @@ def inference(raw_image, question):
191
  mask = last_am[0, :].reshape(14,14).cpu().numpy()
192
  mask = cv2.resize(mask / mask.max(), oimg.size)[..., np.newaxis]
193
  attention_map = (mask * oimg).astype("uint8")
194
- return seq.split("because")[0].strip(), "because " + " ".join(seq.split("because")[-1].strip()), Image.fromarray(attention_map)
 
195
 
196
  inputs = [gr.inputs.Image(type='pil', label="Load the image of your interest"), gr.inputs.Textbox(label="Ask a question on this image")]
197
  outputs = [gr.outputs.Textbox(label="Answer"), gr.outputs.Textbox(label="Textual Explanation"), gr.outputs.Image(type='pil', label="Visual Explanation")]
 
191
  mask = last_am[0, :].reshape(14,14).cpu().numpy()
192
  mask = cv2.resize(mask / mask.max(), oimg.size)[..., np.newaxis]
193
  attention_map = (mask * oimg).astype("uint8")
194
+ splitted_seq = seq.split("because")
195
+ return splitted_seq[0].strip(), "because " + " ".join(splitted_seq[-1].strip()), Image.fromarray(attention_map)
196
 
197
  inputs = [gr.inputs.Image(type='pil', label="Load the image of your interest"), gr.inputs.Textbox(label="Ask a question on this image")]
198
  outputs = [gr.outputs.Textbox(label="Answer"), gr.outputs.Textbox(label="Textual Explanation"), gr.outputs.Image(type='pil', label="Visual Explanation")]