2 Copyright (c) 2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
18 from accuracy_checker.metrics.reid import eval_cmc
22 def test_only_distance_matrix(self):
23 distance_matrix = np.array([
30 m, n = distance_matrix.shape
34 query_ids=np.arange(m),
35 gallery_ids=np.arange(n),
36 query_cams=np.zeros(m).astype(np.int32),
37 gallery_cams=np.ones(n).astype(np.int32)
40 assert np.all(result[:5] == [0.6, 0.6, 0.8, 1.0, 1.0])
42 def test_duplicate_ids(self):
43 distance_matrix = np.array([
52 query_ids=np.array([0, 0, 1, 1]),
53 gallery_ids=np.array([0, 0, 1, 1]),
55 gallery_cams=np.ones(distance_matrix.shape[1]).astype(np.int32),
56 query_cams=np.zeros(distance_matrix.shape[0]).astype(np.int32),
57 separate_camera_set=False,
58 single_gallery_shot=False
61 assert np.all(result == [0.5, 0.5, 1, 1])
63 def test_duplicate_cams(self):
64 distance_matrix = np.tile(np.arange(5), (5, 1))
68 query_ids=np.array([0, 0, 0, 1, 1]),
69 gallery_ids=np.array([0, 0, 0, 1, 1]),
70 query_cams=np.array([0, 0, 0, 0, 0]),
71 gallery_cams=np.array([0, 1, 1, 1, 1]),
73 separate_camera_set=False,
74 single_gallery_shot=False
77 assert np.all(result == [0.6, 0.6, 0.6, 1, 1])