Skip to content

Commit

Permalink
AC: add Mapillary dataset support (openvinotoolkit#1735)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Nov 3, 2020
1 parent 723726c commit 33bc4be
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ Accuracy Checker supports following list of annotation converters and specific f
* `images_suffix` - suffix for image file names (Optional, default `_leftImg8bit`).
* `use_full_label_map` - allows to use full label map with 33 classes instead train label map with 18 classes (Optional, default `False`).
* `dataset_meta_file` - path path to json file with dataset meta (e.g. label_map, color_encoding).Optional, more details in [Customizing dataset meta](#customizing-dataset-meta) section.
* `mapillary_20` - converts Mapillary dataset contained 20 classes to `SegmentationAnnotation`.
* `data_dir` - path to dataset root folder. Relative paths to images and masks directory determine as `imgs` and `masks` respectively. In way when images and masks are located in non default directories, you can use parameters described below.
* `images_dir` - path to images folder.
* `mask_dir` - path to ground truth mask folder.
* `vgg_face` - converts VGG Face 2 dataset for facial landmarks regression task to `FacialLandmarksAnnotation`.
* `landmarks_csv_file` - path to csv file with coordinates of landmarks points.
* `bbox_csv_file` - path to cvs file which contains bounding box coordinates for faces (optional parameter).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
from .place_recognition import PlaceRecognitionDatasetConverter
from .cluttered_mnist import ClutteredMNISTConverter
from .mpii import MPIIDatasetConverter
from .mapillary_20 import Mapillary20Converter

__all__ = [
'BaseFormatConverter',
Expand Down Expand Up @@ -117,6 +118,7 @@
'MSCocoSingleKeypointsConverter',
'MSCocoDetectionConverter',
'CityscapesConverter',
'Mapillary20Converter',
'MovieLensConverter',
'BratsConverter',
'BratsNumpyConverter',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
Copyright (c) 2018-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from ..config import PathField
from ..representation import SegmentationAnnotation
from ..representation.segmentation_representation import GTMaskLoader
from ..utils import get_path
from .format_converter import BaseFormatConverter, ConverterReturn


class Mapillary20Converter(BaseFormatConverter):
__provider__ = 'mapillary_20'
annotation_types = (SegmentationAnnotation, )

label_map = {
0: 'Road',
1: 'Sidewalk',
2: 'Building',
3: 'Wall',
4: 'Fence',
5: 'Pole',
6: 'Traffic Light',
7: 'Traffic Sign',
8: 'Vegetation',
9: 'Terrain',
10: 'Sky',
11: 'Person',
12: 'Rider',
13: 'Car',
14: 'Truck',
15: 'Bus',
16: 'Train',
17: 'Motorcycle',
18: 'Bicycle',
19: 'Ego-Vehicle'
}

@classmethod
def parameters(cls):
parameters = super().parameters()
parameters.update({
'data_dir': PathField(
is_directory=True,
description="Path to dataset root folder. Relative paths to images and masks directory "
"determine as imgs and masks respectively. "
"In way when images and masks are located in non default directories, "
"you can use parameters described below."
),
'images_dir': PathField(
optional=True, is_directory=True, check_exists=False,
default='imgs', description="Path to images folder."
),
'mask_dir': PathField(
optional=True, is_directory=True, check_exists=False,
default='masks', description="Path to ground truth mask folder."
)
})

return parameters

def configure(self):
data_dir = self.get_value_from_config('data_dir')
image_folder = self.get_value_from_config('images_dir')
mask_folder = self.get_value_from_config('mask_dir')
if data_dir:
image_folder = data_dir / image_folder
mask_folder = data_dir / mask_folder
self.images_dir = get_path(image_folder, is_directory=True)
self.mask_dir = get_path(mask_folder, is_directory=True)

def convert(self, *args, **kwargs):
annotations = []
for file_in_dir in self.images_dir.iterdir():
annotation = SegmentationAnnotation(file_in_dir.name, file_in_dir.name, mask_loader=GTMaskLoader.PILLOW)
annotations.append(annotation)

return ConverterReturn(annotations, {'label_map': self.label_map}, None)
7 changes: 7 additions & 0 deletions tools/accuracy_checker/dataset_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ datasets:
annotation: voc2012_segmentation.pickle
dataset_meta: voc2012_segmentation.json

- name: mapillary_20
annotation_conversion:
converter: mapillary_20
data_dir: Mapillary_20
annotation: mapillary_20.pickle
dataset_meta: mapillary_20.json

- name: wider
data_source: WIDER_val/images
annotation_conversion:
Expand Down

0 comments on commit 33bc4be

Please sign in to comment.