Spaces:
Sleeping
Sleeping
Update generic.py
Browse files- generic.py +4 -1
generic.py
CHANGED
@@ -119,11 +119,14 @@ def save_image_vis(image_file_path, question):
|
|
119 |
cv2.imwrite(
|
120 |
'lxmert/experiments/paper/new.jpg', img)
|
121 |
img = Image.open('lxmert/experiments/paper/new.jpg')
|
|
|
|
|
|
|
122 |
text_scores = (text_scores - text_scores.min()) / (text_scores.max() - text_scores.min())
|
123 |
vis_data_records = [visualization.VisualizationDataRecord(text_scores, 0, 0, 0, 0, 0, model_lrp.question_tokens, 1)]
|
124 |
html1 = visualization.visualize_text(vis_data_records)
|
125 |
answer = vqa_answers[model_lrp.output.question_answering_score.argmax()]
|
126 |
-
return img, html1.data, answer
|
127 |
|
128 |
|
129 |
|
|
|
119 |
cv2.imwrite(
|
120 |
'lxmert/experiments/paper/new.jpg', img)
|
121 |
img = Image.open('lxmert/experiments/paper/new.jpg')
|
122 |
+
img = img.resize([448, 300])
|
123 |
+
orig_image = Image.open(image_file_path)
|
124 |
+
orig_image = orig_image.resize([448, 300])
|
125 |
text_scores = (text_scores - text_scores.min()) / (text_scores.max() - text_scores.min())
|
126 |
vis_data_records = [visualization.VisualizationDataRecord(text_scores, 0, 0, 0, 0, 0, model_lrp.question_tokens, 1)]
|
127 |
html1 = visualization.visualize_text(vis_data_records)
|
128 |
answer = vqa_answers[model_lrp.output.question_answering_score.argmax()]
|
129 |
+
return orig_image, img, html1.data, answer
|
130 |
|
131 |
|
132 |
|