Publishing 2019 R1 content
[platform/upstream/dldt.git] / tools / accuracy_checker / accuracy_checker / annotation_converters / market1501.py
1 """
2 Copyright (c) 2019 Intel Corporation
3
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
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
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.
15 """
16
17 from __future__ import absolute_import, print_function
18
19 import re
20
21 from ._reid_common import check_dirs, read_directory
22 from .format_converter import DirectoryBasedAnnotationConverter
23
24 MARKET_IMAGE_PATTERN = re.compile(r'([-\d]+)_c(\d)')
25
26
27 class Market1501Converter(DirectoryBasedAnnotationConverter):
28     __provider__ = "market1501"
29
30     def convert(self):
31         gallery = self.data_dir / 'bounding_box_test'
32         query = self.data_dir / 'query'
33
34         check_dirs((gallery, query), self.data_dir)
35         gallery_images, gallery_pids = read_directory(gallery, query=False, image_pattern=MARKET_IMAGE_PATTERN)
36         query_images, query_pids = read_directory(query, query=True, image_pattern=MARKET_IMAGE_PATTERN)
37         annotation = gallery_images + query_images
38
39         meta = {'num_identities': len(gallery_pids | query_pids)}
40
41         return annotation, meta