Skip to content

Fix metric computation when the GT is empty

We need to handle the case where the GT is empty in dan/ocr/manager/metrics.py

  File "/gpfsdswork/projects/rech/zyg/uoh22tq/dan/lib/python3.10/site-packages/dan/ocr/train.py", line 49, in train
    model.train(mlflow_logging=mlflow_logging)
  File "/gpfsdswork/projects/rech/zyg/uoh22tq/dan/lib/python3.10/site-packages/dan/ocr/manager/training.py", line 653, in train
    batch_metrics = self.metric_manager["train"].compute_metrics(
  File "/gpfsdswork/projects/rech/zyg/uoh22tq/dan/lib/python3.10/site-packages/dan/ocr/manager/metrics.py", line 207, in compute_metrics
    metrics[keyword + "_error_rate" + suffix] = [
  File "/gpfsdswork/projects/rech/zyg/uoh22tq/dan/lib/python3.10/site-packages/dan/ocr/manager/metrics.py", line 208, in <listcomp>
    round(float(edit_dist / gt_len), 4)
ZeroDivisionError: division by zero