# HmeanIOUMetric¶

class mmocr.evaluation.metrics.HmeanIOUMetric(match_iou_thr=0.5, ignore_precision_thr=0.5, pred_score_thrs={'start': 0.3, 'step': 0.1, 'stop': 0.9}, strategy='vanilla', collect_device='cpu', prefix=None)[source]

HmeanIOU metric.

This method computes the hmean iou metric, which is done in the following steps:

• Filter the prediction polygon:

• Scores is smaller than minimum prediction score threshold.

• The proportion of the area that intersects with gt ignored polygon is greater than ignore_precision_thr.

• Computing an M x N IoU matrix, where each element indexing E_mn represents the IoU between the m-th valid GT and n-th valid prediction.

• Based on different prediction score threshold: - Obtain the ignored predictions according to prediction score.

The filtered predictions will not be involved in the later metric computations.

• Based on the IoU matrix, get the match metric according to

match_iou_thr. - Based on different strategy, accumulate the match number.

• calculate H-mean under different prediction score threshold.

Parameters
• match_iou_thr (float) – IoU threshold for a match. Defaults to 0.5.

• ignore_precision_thr (float) – Precision threshold when prediction and gt ignored polygons are matched. Defaults to 0.5.

• pred_score_thrs (dict) – Best prediction score threshold searching space. Defaults to dict(start=0.3, stop=0.9, step=0.1).

• strategy (str) – Polygon matching strategy. Options are ‘max_matching’ and ‘vanilla’. ‘max_matching’ refers to the optimum strategy that maximizes the number of matches. Vanilla strategy matches gt and pred polygons if both of them are never matched before. It was used in MMOCR 0.x and and academia. Defaults to ‘vanilla’.

• collect_device (str) – Device name used for collecting results from different ranks during distributed training. Must be ‘cpu’ or ‘gpu’. Defaults to ‘cpu’.

• prefix (str, optional) – The prefix that will be added in the metric names to disambiguate homonymous metrics of different evaluators. If prefix is not provided in the argument, self.default_prefix will be used instead. Defaults to None

Return type

None

compute_metrics(results)[source]

Compute the metrics from processed results.

Parameters

results (list[dict]) – The processed results of each batch.

Returns

The computed metrics. The keys are the names of the metrics, and the values are corresponding results.

Return type

dict

process(data_batch, data_samples)[source]

Process one batch of data samples and predictions. The processed results should be stored in self.results, which will be used to compute the metrics when all batches have been processed.

Parameters
• data_batch (Sequence[Dict]) – A batch of data from dataloader.

• data_samples (Sequence[Dict]) – A batch of outputs from the model.

Return type

None