`ZeroDivisionError` not handled

#2
by kevinconka - opened
SEA.AI org
from pprint import pprint
import evaluate
from seametrics.payload.processor import PayloadProcessor

payload = PayloadProcessor(
        dataset_name="SENTRY_VIDEOS_DATASET_QA",
        gt_field="ground_truth_det_fused_id",
        models=["ahoy_IR_b2_engine_3_6_0_49_gd81d3b63_oversea"],
        sequence_list=["Sentry_2023_02_08_PROACT_CELADON_@6m_MOB_2023_02_08_12_51_49"],
        # tags=["GT_ID_FUSION"],
        tracking_mode=True
   ).payload

module = evaluate.load("SEA-AI/user-friendly-metrics")
res = module._compute(payload, max_iou=0.0001, recognition_thresholds=[0.3, 0.5, 0.8])
pprint(res)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In[37], line 15
      5 payload = PayloadProcessor(
      6         dataset_name="SENTRY_VIDEOS_DATASET_QA",
      7         gt_field="ground_truth_det_fused_id",
   (...)
     11         tracking_mode=True
     12    ).payload
     14 module = evaluate.load("SEA-AI/user-friendly-metrics")
---> 15 res = module._compute(payload, max_iou=0.0001, recognition_thresholds=[0.3, 0.5, 0.8])
     16 pprint(res)

File ~/.cache/huggingface/modules/evaluate_modules/metrics/SEA-AI--user-friendly-metrics/b68dfd5cafe3584a29303a6dfa35fed38b0b0b0659885ab714eb6fd00cf1bb6e/user-friendly-metrics.py:97, in UserFriendlyMetrics._compute(self, payload, max_iou, filters, recognition_thresholds, debug)
     95 """Returns the scores"""
     96 # TODO: Compute the different scores of the module
---> 97 return calculate_from_payload(payload, max_iou, filters, recognition_thresholds, debug)

File ~/.cache/huggingface/modules/evaluate_modules/metrics/SEA-AI--user-friendly-metrics/b68dfd5cafe3584a29303a6dfa35fed38b0b0b0659885ab714eb6fd00cf1bb6e/user-friendly-metrics.py:260, in calculate_from_payload(payload, max_iou, filters, recognition_thresholds, debug)
    257 else:
    259     sequence_metrics = calculate(formated_predictions, all_formated_references["all"], max_iou=max_iou, recognition_thresholds = recognition_thresholds)
--> 260     sequence_metrics = realize_metrics(sequence_metrics, recognition_thresholds)
    261     metrics_per_sequence[sequence][model]["all"] = sequence_metrics
    263     metrics_global[model]["all"] = sum_dicts(metrics_global[model]["all"], sequence_metrics)

File ~/.cache/huggingface/modules/evaluate_modules/metrics/SEA-AI--user-friendly-metrics/b68dfd5cafe3584a29303a6dfa35fed38b0b0b0659885ab714eb6fd00cf1bb6e/user-friendly-metrics.py:309, in realize_metrics(metrics_dict, recognition_thresholds)
    307 metrics_dict["precision"] = metrics_dict["tp"]/(metrics_dict["tp"]+metrics_dict["fp"])
    308 metrics_dict["recall"] = metrics_dict["tp"]/(metrics_dict["tp"]+metrics_dict["fn"])
--> 309 metrics_dict["f1"] = 2*metrics_dict["precision"]*metrics_dict["recall"]/(metrics_dict["precision"]+metrics_dict["recall"])
    311 for th in recognition_thresholds:
    312     metrics_dict[f"recognition_{th}"] = metrics_dict[f"recognized_{th}"]/metrics_dict["num_gt_ids"]

ZeroDivisionError: float division by zero
SEA.AI org

fixed. thanks!

the fix (add eps)

metrics_dict["f1"] = 2*metrics_dict["precision"]*metrics_dict["recall"]/(metrics_dict["precision"]+metrics_dict["recall"]+1e-6)

SEA.AI org

Screenshot from 2024-11-27 12-37-16.png

Sign up or log in to comment