diff --git a/mediapipe/tasks/python/test/vision/object_detector_test.py b/mediapipe/tasks/python/test/vision/object_detector_test.py index 58b549c12..b1198a952 100644 --- a/mediapipe/tasks/python/test/vision/object_detector_test.py +++ b/mediapipe/tasks/python/test/vision/object_detector_test.py @@ -138,7 +138,7 @@ class ObjectDetectorTest(parameterized.TestCase): os.path.join(_TEST_DATA_DIR, _MODEL_FILE) ) - def _assert_approximately_equals_bounding_box(self, bbox, expected_bbox): + def _expect_bounding_box_correct(self, bbox, expected_bbox): self.assertEqual(bbox.width, expected_bbox.width) self.assertEqual(bbox.height, expected_bbox.height) self.assertAlmostEqual( @@ -148,21 +148,21 @@ class ObjectDetectorTest(parameterized.TestCase): bbox.origin_y, expected_bbox.origin_y, _PIXEL_DIFF_TOLERANCE ) - def _assert_approximately_equals_category(self, category, expected_category): + def _expect_category_correct(self, category, expected_category): self.assertEqual(category.category_name, expected_category.category_name) self.assertAlmostEqual( category.score, expected_category.score, _SCORE_DIFF_TOLERANCE ) - def _assert_approximately_equals_detection_result(self, result, expected_result): + def _expect_detection_result_correct(self, result, expected_result): self.assertLen(result.detections, len(expected_result.detections)) for i, detection in enumerate(result.detections): bbox = detection.bounding_box category = detection.categories[0] expected_bbox = expected_result.detections[i].bounding_box expected_category = expected_result.detections[i].categories[0] - self._assert_approximately_equals_bounding_box(bbox, expected_bbox) - self._assert_approximately_equals_category(category, expected_category) + self._expect_bounding_box_correct(bbox, expected_bbox) + self._expect_category_correct(category, expected_category) def test_create_from_file_succeeds_with_valid_model_path(self): # Creates with default option and valid model file successfully. @@ -220,7 +220,7 @@ class ObjectDetectorTest(parameterized.TestCase): # Performs object detection on the input. detection_result = detector.detect(self.test_image) # Comparing results. - self._assert_approximately_equals_detection_result( + self._expect_detection_result_correct( detection_result, expected_detection_result ) # Closes the detector explicitly when the detector is not used in @@ -435,7 +435,7 @@ class ObjectDetectorTest(parameterized.TestCase): with _ObjectDetector.create_from_options(options) as detector: for timestamp in range(0, 300, 30): detection_result = detector.detect_for_video(self.test_image, timestamp) - self._assert_approximately_equals_detection_result( + self._expect_detection_result_correct( detection_result, _EXPECTED_DETECTION_RESULT ) @@ -487,7 +487,7 @@ class ObjectDetectorTest(parameterized.TestCase): result: _DetectionResult, output_image: _Image, timestamp_ms: int ): if result.detections: - self._assert_approximately_equals_detection_result( + self._expect_detection_result_correct( result, expected_result ) else: