Spaces:
Build error
Build error
MikailDuzenli
commited on
Commit
•
abc7e19
1
Parent(s):
d34cc3f
Show image and heatmap at the same time
Browse files
app.py
CHANGED
@@ -171,6 +171,7 @@ def infer(url, mp_text, hidx):
|
|
171 |
encoded = processor.tokenizer(inferred_token)
|
172 |
output = processor.decode(encoded.input_ids[0], skip_special_tokens=True)
|
173 |
selected_token = ''
|
|
|
174 |
|
175 |
if hidx > 0 and hidx < len(encoded["input_ids"][0][:-1]):
|
176 |
input_ids = torch.tensor(encoded.input_ids)
|
@@ -253,13 +254,13 @@ def infer(url, mp_text, hidx):
|
|
253 |
)
|
254 |
image_rgba = image.copy()
|
255 |
image_rgba.putalpha(overlay)
|
256 |
-
|
257 |
|
258 |
selected_token = processor.tokenizer.convert_ids_to_tokens(
|
259 |
encoded["input_ids"][0][hidx]
|
260 |
)
|
261 |
|
262 |
-
return [np.array(image), output, selected_token]
|
263 |
|
264 |
|
265 |
title = "What's in the picture ?"
|
@@ -289,6 +290,7 @@ outputs_interface = [
|
|
289 |
gr.outputs.Image(label="Image"),
|
290 |
gr.outputs.Textbox(label="description"),
|
291 |
gr.outputs.Textbox(label="selected token"),
|
|
|
292 |
]
|
293 |
|
294 |
interface = gr.Interface(
|
|
|
171 |
encoded = processor.tokenizer(inferred_token)
|
172 |
output = processor.decode(encoded.input_ids[0], skip_special_tokens=True)
|
173 |
selected_token = ''
|
174 |
+
result = None
|
175 |
|
176 |
if hidx > 0 and hidx < len(encoded["input_ids"][0][:-1]):
|
177 |
input_ids = torch.tensor(encoded.input_ids)
|
|
|
254 |
)
|
255 |
image_rgba = image.copy()
|
256 |
image_rgba.putalpha(overlay)
|
257 |
+
result = image_rgba
|
258 |
|
259 |
selected_token = processor.tokenizer.convert_ids_to_tokens(
|
260 |
encoded["input_ids"][0][hidx]
|
261 |
)
|
262 |
|
263 |
+
return [np.array(image), output, selected_token, result]
|
264 |
|
265 |
|
266 |
title = "What's in the picture ?"
|
|
|
290 |
gr.outputs.Image(label="Image"),
|
291 |
gr.outputs.Textbox(label="description"),
|
292 |
gr.outputs.Textbox(label="selected token"),
|
293 |
+
gr.outputs.Image(label="Heatmap")
|
294 |
]
|
295 |
|
296 |
interface = gr.Interface(
|