jw2yang commited on
Commit
1f3181a
1 Parent(s): 695ed52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -130,8 +130,9 @@ def recognize_image(image, texts):
130
  output_map = output_map.squeeze(1).detach().permute(1, 2, 0).numpy()
131
  output_map = (output_map - output_map.min()) / (output_map.max() - output_map.min())
132
  heatmap = show_cam_on_image(img_d, output_map, use_rgb=True)
133
-
134
- return {texts.split(';')[i]: float(prediction[i]) for i in range(len(texts.split(';')))}, Image.fromarray(np.uint8(255 * img_d)), Image.fromarray(heatmap)
 
135
 
136
 
137
  image = gr.inputs.Image()
@@ -145,10 +146,7 @@ gr.Interface(
145
  label,
146
  gr.outputs.Image(
147
  type="pil",
148
- label="crop input"),
149
- gr.outputs.Image(
150
- type="pil",
151
- label="zero-shot heat map"),
152
  ],
153
  examples=[
154
  ["./elephants.png", "an elephant; an elephant walking in the river; four elephants walking in the river"],
 
130
  output_map = output_map.squeeze(1).detach().permute(1, 2, 0).numpy()
131
  output_map = (output_map - output_map.min()) / (output_map.max() - output_map.min())
132
  heatmap = show_cam_on_image(img_d, output_map, use_rgb=True)
133
+
134
+ show_img = np.concatenate((np.uint8(255 * img_d), heatmap), 1)
135
+ return {texts.split(';')[i]: float(prediction[i]) for i in range(len(texts.split(';')))}, Image.fromarray(show_img)
136
 
137
 
138
  image = gr.inputs.Image()
 
146
  label,
147
  gr.outputs.Image(
148
  type="pil",
149
+ label="crop input/heat map"),
 
 
 
150
  ],
151
  examples=[
152
  ["./elephants.png", "an elephant; an elephant walking in the river; four elephants walking in the river"],