Update vqa_metric.py

This commit is contained in:
99Franklin
2025-07-05 10:32:27 +08:00
committed by GitHub
parent b5ecad3e34
commit 161c6dfbea

View File

@@ -53,14 +53,14 @@ def vqa_evaluation(predict, answers):
if len(answers.split()) < 5: if len(answers.split()) < 5:
if answers in predict: if answers in predict:
score = 1 score = 1
else: else:
dist = levenshtein_distance(predict, answers) dist = levenshtein_distance(predict, answers)
length = max(len(predict), len(answers)) length = max(len(predict), len(answers))
ANLS_value = 0.0 if length == 0 else float(dist) / float(length) ANLS_value = 0.0 if length == 0 else float(dist) / float(length)
ANLS_value = 1 - ANLS_value ANLS_value = 1 - ANLS_value
if ANLS_value >= 0.5 and ANLS_value > score: if ANLS_value >= 0.5 and ANLS_value > score:
score = ANLS_value score = ANLS_value
return score return score