torchocr.metrics#
- class torchocr.metrics.DetectionHmean(iou_threshold=0.5, ignore_threshold=0.5)[source]#
Bases:
objectICDAR-2015 text-detection precision / recall / hmean.
Reproduces the official RRC “IoU” evaluation (the protocol behind every published ICDAR-2015 detection number, and PaddleOCR’s
DetectionIoUEvaluator):Polygons that are not valid (e.g. self-intersecting) are dropped.
A prediction is don’t care if more than
ignore_thresholdof its own area lies inside a single ignored ground-truth region (###transcriptions in ICDAR files).Remaining pairs are matched greedily and one-to-one in (ground truth, prediction) order whenever IoU >
iou_threshold.Matches and care counts are summed over all images before the ratios are taken, so large images are not averaged away.
Usage follows the stateful-metric idiom:
metric = DetectionHmean() for preds, target in loader: metric.update(preds, target.polygons, target.ignore) result = metric.compute() # HmeanResult
- Parameters:
- class torchocr.metrics.EndToEndHmean(iou_threshold=0.5, ignore_threshold=0.5, case_sensitive=False, alphanumeric_only=True)[source]#
Bases:
DetectionHmeanEnd-to-end text spotting hmean: a detection counts only if it is also read correctly.
Regions are matched exactly as in
DetectionHmean; a matched pair is a true positive only when the normalized transcriptions are equal. This follows the ICDAR-2015 end-to-end task with a generic vocabulary (no lexicon), simplified: text equality usesRecognitionAccuracy’s normalization instead of the official script’s special-character rules.- Parameters:
iou_threshold (float) – As in
DetectionHmean.ignore_threshold (float) – As in
DetectionHmean.case_sensitive (bool) – Text normalization before comparison. Defaults follow the scene-text convention (case-insensitive, letters and digits only).
alphanumeric_only (bool) – Text normalization before comparison. Defaults follow the scene-text convention (case-insensitive, letters and digits only).
- class torchocr.metrics.HmeanResult(precision, recall, hmean, num_matched, num_gt, num_pred)[source]#
Bases:
objectDataset-level detection scores under the ICDAR IoU protocol.
num_gtandnum_predexclude don’t-care regions and invalid polygons; they are the denominators ofrecallandprecision.
- class torchocr.metrics.RecognitionAccuracy(case_sensitive=True, alphanumeric_only=False)[source]#
Bases:
objectWord accuracy and character error rate over (prediction, target) string pairs.
case_sensitive=False, alphanumeric_only=Trueis the usual scene-text protocol (ICDAR / IIIT5K / SVT report “case-insensitive word accuracy” over letters and digits).