From f1034bd5a821e7fa4ab9a4f13d0a20981b2fe845 Mon Sep 17 00:00:00 2001 From: homuler Date: Thu, 26 Aug 2021 12:27:46 +0900 Subject: [PATCH] fix: check if roi width and height is NaN --- .../calculators/tensor/tensors_to_detections_calculator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc b/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc index f161127f5..a44deb853 100644 --- a/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc +++ b/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc @@ -670,7 +670,7 @@ absl::Status TensorsToDetectionsCalculator::ConvertToDetections( detection_boxes[box_offset + 2], detection_boxes[box_offset + 3], detection_scores[i], detection_classes[i], options_.flip_vertically()); const auto& bbox = detection.location_data().relative_bounding_box(); - if (bbox.width() < 0 || bbox.height() < 0) { + if (bbox.width() < 0 || bbox.height() < 0 || std::isnan(bbox.width()) || std::isnan(bbox.height())) { // Decoded detection boxes could have negative values for width/height due // to model prediction. Filter out those boxes since some downstream // calculators may assume non-negative values. (b/171391719)