Skip to content

Commit 1df6e4e

Browse files
update anls metric
PiperOrigin-RevId: 563571566
1 parent 380fc5f commit 1df6e4e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pix2struct/metrics.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ def cider(
5656

5757

5858
def anls_metric(target: str, prediction: str, theta: float = 0.5):
59-
"""Calculates ANLS for DocVQA.
59+
"""Calculates ANLS for DocVQA and InfographicVQA.
6060
61-
There does not seem to be an official evaluation script.
62-
Public implementation on which this implementation is based:
63-
https://github.com/herobd/layoutlmv2/blob/main/eval_docvqa.py#L92
61+
Official evaluation script at https://rrc.cvc.uab.es/?ch=17&com=downloads
62+
(Infographics VQA Evaluation scripts).
6463
6564
Original paper (see Eq 1): https://arxiv.org/pdf/1907.00490.pdf
6665
@@ -75,7 +74,7 @@ def anls_metric(target: str, prediction: str, theta: float = 0.5):
7574

7675
edit_distance = editdistance.eval(target, prediction)
7776
normalized_ld = edit_distance / max(len(target), len(prediction))
78-
return 1 - normalized_ld if normalized_ld < theta else 0
77+
return 1 - normalized_ld if normalized_ld <= theta else 0
7978

8079

8180
def relaxed_correctness(target: str,

0 commit comments

Comments
 (0)