Skip to content

Commit 9580d5d

Browse files
author
Maxim Zhiltsov
authored
Merge pull request #185 from openvinotoolkit/develop
Release v0.1.7
2 parents e474187 + f21f71d commit 9580d5d

File tree

80 files changed

+6892
-870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+6892
-870
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ matrix:
3131
install:
3232
- pip install -e ./
3333
- pip install tensorflow
34+
- pip install pandas
3435

3536
script:
3637
- python -m unittest discover -v

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## 24/03/2021 - Release v0.1.7
10+
### Added
11+
- OpenVINO plugin examples (<https://github.com/openvinotoolkit/datumaro/pull/159>)
12+
- Dataset validation for classification and detection datasets (<https://github.com/openvinotoolkit/datumaro/pull/160>)
13+
- Arbitrary image extensions in formats (import and export) (<https://github.com/openvinotoolkit/datumaro/issues/166>)
14+
- Ability to set a custom subset name for an imported dataset (<https://github.com/openvinotoolkit/datumaro/issues/166>)
15+
- CLI support for NDR(<https://github.com/openvinotoolkit/datumaro/pull/178>)
16+
17+
### Changed
18+
- Common ICDAR format is split into 3 sub-formats (<https://github.com/openvinotoolkit/datumaro/pull/174>)
19+
20+
### Deprecated
21+
-
22+
23+
### Removed
24+
-
25+
26+
### Fixed
27+
- The ability to work with file names containing Cyrillic and spaces (<https://github.com/openvinotoolkit/datumaro/pull/148>)
28+
- Image reading and saving in ICDAR formats (<https://github.com/openvinotoolkit/datumaro/pull/174>)
29+
- Unnecessary image loading on dataset saving (<https://github.com/openvinotoolkit/datumaro/pull/176>)
30+
- Allowed spaces in ICDAR captions (<https://github.com/openvinotoolkit/datumaro/pull/182>)
31+
- Saving of masks in VOC when masks are not requested (<https://github.com/openvinotoolkit/datumaro/pull/184>)
32+
33+
### Security
34+
-
35+
936
## 03/02/2021 - Release v0.1.6.1 (hotfix)
1037
### Added
1138
-
@@ -34,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3461
- `LFW` dataset format (<https://github.com/openvinotoolkit/datumaro/pull/110>)
3562
- Support of polygons' and masks' confusion matrices and mismathing classes in `diff` command (<https://github.com/openvinotoolkit/datumaro/pull/117>)
3663
- Add near duplicate image removal plugin (<https://github.com/openvinotoolkit/datumaro/pull/113>)
64+
- Sampler Plugin that analyzes inference result from the given dataset and selects samples for annotation(<https://github.com/openvinotoolkit/datumaro/pull/115>)
3765

3866
### Changed
3967
- OpenVINO model launcher is updated for OpenVINO r2021.1 (<https://github.com/openvinotoolkit/datumaro/pull/100>)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ CVAT annotations ---> Publication, statistics etc.
158158
- for detection task, based on bboxes
159159
- for re-identification task, based on labels,
160160
avoiding having same IDs in training and test splits
161+
- Sampling a dataset
162+
- analyzes inference result from the given dataset
163+
and selects the ‘best’ and the ‘least amount of’ samples for annotation.
164+
- Select the sample that best suits model training.
165+
- sampling with Entropy based algorithm
161166
- Dataset quality checking
162167
- Simple checking for errors
163168
- Comparison with model infernece

datumaro/cli/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def make_parser():
7777
('stats', commands.stats, "Compute project statistics"),
7878
('info', commands.info, "Print project info"),
7979
('explain', commands.explain, "Run Explainable AI algorithm for model"),
80+
('validate', commands.validate, "Validate project")
8081
]
8182

8283
# Argparse doesn't support subparser groups:

datumaro/cli/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
explain,
1010
export, merge, convert, transform, filter,
1111
diff, ediff, stats,
12-
info
12+
info, validate
1313
)

datumaro/cli/commands/validate.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (C) 2020-2021 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
# pylint: disable=unused-import
6+
7+
from ..contexts.project import build_validate_parser as build_parser

datumaro/cli/contexts/project/__init__.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
import shutil
1111
from enum import Enum
1212

13-
from datumaro.components.cli_plugin import CliPlugin
1413
from datumaro.components.dataset_filter import DatasetItemEncoder
1514
from datumaro.components.extractor import AnnotationType
1615
from datumaro.components.operations import (DistanceComparator,
17-
ExactComparator, compute_ann_statistics, compute_image_statistics, mean_std)
16+
ExactComparator, compute_ann_statistics, compute_image_statistics)
1817
from datumaro.components.project import \
1918
PROJECT_DEFAULT_CONFIG as DEFAULT_CONFIG
2019
from datumaro.components.project import Environment, Project
20+
from datumaro.components.validator import validate_annotations, TaskType
2121
from datumaro.util import error_rollback
2222

2323
from ...util import (CliException, MultilineFormatter, add_subparser,
@@ -791,6 +791,51 @@ def print_extractor_info(extractor, indent=''):
791791

792792
return 0
793793

794+
def build_validate_parser(parser_ctor=argparse.ArgumentParser):
795+
parser = parser_ctor(help="Validate project",
796+
description="""
797+
Validates project based on specified task type and stores
798+
results like statistics, reports and summary in JSON file.
799+
""",
800+
formatter_class=MultilineFormatter)
801+
802+
parser.add_argument('task_type',
803+
choices=[task_type.name for task_type in TaskType],
804+
help="Task type for validation")
805+
parser.add_argument('-s', '--subset', dest='subset_name', default=None,
806+
help="Subset to validate (default: None)")
807+
parser.add_argument('-p', '--project', dest='project_dir', default='.',
808+
help="Directory of the project to validate (default: current dir)")
809+
parser.set_defaults(command=validate_command)
810+
811+
return parser
812+
813+
def validate_command(args):
814+
project = load_project(args.project_dir)
815+
task_type = args.task_type
816+
subset_name = args.subset_name
817+
dst_file_name = 'validation_results'
818+
819+
dataset = project.make_dataset()
820+
if subset_name is not None:
821+
dataset = dataset.get_subset(subset_name)
822+
dst_file_name += f'-{subset_name}'
823+
validation_results = validate_annotations(dataset, task_type)
824+
825+
def _convert_tuple_keys_to_str(d):
826+
for key, val in list(d.items()):
827+
if isinstance(key, tuple):
828+
d[str(key)] = val
829+
d.pop(key)
830+
if isinstance(val, dict):
831+
_convert_tuple_keys_to_str(val)
832+
833+
_convert_tuple_keys_to_str(validation_results)
834+
835+
dst_file = generate_next_file_name(dst_file_name, ext='.json')
836+
log.info("Writing project validation results to '%s'" % dst_file)
837+
with open(dst_file, 'w') as f:
838+
json.dump(validation_results, f, indent=4, sort_keys=True)
794839

795840
def build_parser(parser_ctor=argparse.ArgumentParser):
796841
parser = parser_ctor(
@@ -814,5 +859,6 @@ def build_parser(parser_ctor=argparse.ArgumentParser):
814859
add_subparser(subparsers, 'transform', build_transform_parser)
815860
add_subparser(subparsers, 'info', build_info_parser)
816861
add_subparser(subparsers, 'stats', build_stats_parser)
862+
add_subparser(subparsers, 'validate', build_validate_parser)
817863

818864
return parser

datumaro/components/converter.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,23 @@ def _find_image_ext(self, item):
5757

5858
return self._image_ext or src_ext or self._default_image_ext
5959

60-
def _make_image_filename(self, item):
61-
return item.id + self._find_image_ext(item)
60+
def _make_image_filename(self, item, *, name=None, subdir=None):
61+
name = name or item.id
62+
subdir = subdir or ''
63+
return osp.join(subdir, name + self._find_image_ext(item))
64+
65+
def _save_image(self, item, path=None, *,
66+
name=None, subdir=None, basedir=None):
67+
assert not ((subdir or name or basedir) and path), \
68+
"Can't use both subdir or name or basedir and path arguments"
6269

63-
def _save_image(self, item, path=None):
6470
if not item.image.has_data:
6571
log.warning("Item '%s' has no image", item.id)
6672
return
6773

68-
path = path or self._make_image_filename(item)
74+
basedir = basedir or self._save_dir
75+
path = path or osp.join(basedir,
76+
self._make_image_filename(item, name=name, subdir=subdir))
6977
path = osp.abspath(path)
7078

7179
src_ext = item.image.ext.lower()

0 commit comments

Comments
 (0)