Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -67,8 +67,15 @@ def generate_answer_vilt(processor, model, image, question):
|
|
67 |
print(torch.softmax(outputs.logits, dim=1))
|
68 |
predicted_class_idx = outputs.logits.argmax(-1).item()
|
69 |
print(f"prdicted_class_idx: {predicted_class_idx}")
|
70 |
-
|
71 |
-
print(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
return model.config.id2label[predicted_class_idx]
|
73 |
|
74 |
|
|
|
67 |
print(torch.softmax(outputs.logits, dim=1))
|
68 |
predicted_class_idx = outputs.logits.argmax(-1).item()
|
69 |
print(f"prdicted_class_idx: {predicted_class_idx}")
|
70 |
+
logitsList = outputs.logits.flatten().tolist()
|
71 |
+
print(f"predicted_class_idx_in_list = {logitsList.index(max(logitsList))}")
|
72 |
+
m = max(logitsList)
|
73 |
+
s = -math.infinity
|
74 |
+
for logit in logitsList:
|
75 |
+
if s <= logit < m:
|
76 |
+
s = logit
|
77 |
+
print(f"runnerup_idx_in_list = {logitsList.index(s)}")
|
78 |
+
print(f"runnerup val: {model.config.id2label[logitsList.index(s)]}")
|
79 |
return model.config.id2label[predicted_class_idx]
|
80 |
|
81 |
|