@@ -0,0 +1,2052 @@
+# Copyright 2020 Google Research. All Rights Reserved.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A# ==============================================================================%0A%22%22%22Tests for coco_metric.%22%22%22%0A%0Afrom absl import logging%0Aimport tensorflow.compat.v1 as tf%0Aimport coco_metric%0A%0A%0Aclass CocoMetricTest(tf.test.TestCase):%0A%0A  def setUp(self):%0A    super(CocoMetricTest, self).setUp()%0A    # %5By1, x1, y2, x2, is_crowd, area, class%5D, in image coords.%0A    self.groundtruth_data = tf.constant(%5B%5B%0A        %5B10.0, 10.0, 20.0, 20.0, 0.0, 100.0, 1%5D,%0A        %5B10.0, 10.0, 30.0, 15.0, 0.0, 100.0, 2%5D,%0A        %5B30.0, 30.0, 40.0, 50.0, 0.0, 100.0, 3%5D%0A    %5D%5D, dtype=tf.float32)%0A    # %5Bimage_id, x, y, width, height, score, class%5D%0A    self.detections = tf.constant(%5B%5B%0A        %5B1.0, 10.0, 10.0, 10.0, 10.0, 0.6, 1%5D,%0A        %5B1.0, 10.0, 10.0, 5.0, 20.0, 0.5, 2%5D%0A    %5D%5D, dtype=tf.float32)%0A    self.class_labels = %7B1: 'car', 2: 'truck', 3: 'bicycle'%7D%0A%0A  def test_mAP(self):%0A%0A    eval_metric = coco_metric.EvaluationMetric(label_map=self.class_labels)%0A    coco_metrics = eval_metric.estimator_metric_fn(self.detections,%0A                                                   self.groundtruth_data)%0A    self.assertEqual(len(coco_metrics.keys()), 15)%0A    self.assertAllClose(coco_metrics%5B'AP'%5D%5B0%5D, 2.0/3.0)%0A    self.assertAllClose(coco_metrics%5B'AP_/car'%5D%5B0%5D, 1.0)%0A    self.assertAllClose(coco_metrics%5B'AP_/truck'%5D%5B0%5D, 1.0)%0A    self.assertAllClose(coco_metrics%5B'AP_/bicycle'%5D%5B0%5D, 0.0)%0A%0A%0Aif __name__ == '__main__':%0A  logging.set_verbosity(logging.WARNING)%0A  tf.test.main()%0A

Add coco_metric test.