Skip to content

Commit 366130d

Browse files
author
Roman Donchenko
authored
Merge pull request openvinotoolkit#1323 from opencv/release
Merge OpenVINO toolkit 2020.4 content into master
2 parents 912eead + 8b5fb94 commit 366130d

File tree

799 files changed

+115197
-9767
lines changed

Some content is hidden

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

799 files changed

+115197
-9767
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The detailed descriptions of file entries provided below.
7272

7373
**`description`**
7474

75-
Description of the model. Must match with the description from the model [documentation](#documentation).
75+
Description of the model. Must match with the description from the model [documentation](#documentation). Use [this](./ci/description_updater/documentation_updater.py) script for easy update.
7676

7777
**`task_type`**
7878

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# [OpenVINO™ Toolkit](https://01.org/openvinotoolkit) - Open Model Zoo repository
2-
[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/opencv/open_model_zoo/releases/tag/2020.3)
2+
[![Stable release](https://img.shields.io/badge/version-2020.4-green.svg)](https://github.com/opencv/open_model_zoo/releases/tag/2020.4)
33
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/open_model_zoo/community)
44
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
55

ci/documentation_updater/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Documentation updater
2+
3+
This script updates description in `model.yml` file according to description in markdown documentation from section *Use Case and High-Level Description*.
4+
5+
## Prerequisites
6+
7+
Install `ruamel.yaml` package:
8+
```
9+
pip install ruamel.yaml
10+
```
11+
12+
## Usage
13+
14+
To update description of single model:
15+
```
16+
python documentation_updater.py -d <OMZ dir>/models/public/<model dir> --mode update
17+
```
18+
19+
To check descriptions of all public models:
20+
```
21+
python documentation_updater.py -d <OMZ dir>/models/public
22+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Copyright (c) 2020 Intel Corporation
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
"""
18+
19+
import argparse
20+
import logging
21+
import re
22+
import ruamel.yaml
23+
import shlex
24+
25+
from pathlib import Path
26+
from ruamel.yaml.scalarstring import FoldedScalarString
27+
from sys import exit
28+
29+
MODES = [
30+
'check',
31+
'update'
32+
]
33+
34+
LOG_LEVELS = [
35+
'CRITICAL',
36+
'ERROR',
37+
'WARNING',
38+
'INFO',
39+
'DEBUG',
40+
]
41+
42+
43+
def parse():
44+
parser = argparse.ArgumentParser()
45+
parser.add_argument('-d', '--model-dir', type=Path, default=Path(__file__).resolve().parents[2] / 'models',
46+
help='Path to root directory with models documentation and configuration files')
47+
parser.add_argument('--mode', type=str, choices=MODES, default='check',
48+
help='Script work mode: "check" only finds diffs, "update" - updates values')
49+
parser.add_argument('--log-level', choices=LOG_LEVELS, default='WARNING',
50+
help='Level of logging')
51+
args = parser.parse_args()
52+
53+
if not args.model_dir.is_dir():
54+
logging.critical("Directory {} does not exist. Please check '--model-dir' option."
55+
.format(args.model_dir))
56+
exit(1)
57+
return args
58+
59+
60+
def collect_readme(directory, ignored_files):
61+
files = {file.stem: file for file in directory.glob('**/*.md') if file.name not in ignored_files}
62+
logging.info('Collected {} description files'.format(len(files)))
63+
if not files:
64+
logging.error("No markdown file found in {}. Exceptions - {}. Ensure, that you set right directory."
65+
.format(directory, ignored_files))
66+
exit(1)
67+
return files
68+
69+
70+
def convert(lines):
71+
result = ''
72+
list_signs = ['-', '*']
73+
for line in lines:
74+
if len(line.strip()) == 0:
75+
result += '\n'
76+
elif line.lstrip()[0] in list_signs:
77+
result += '\n'
78+
if len(result) > 0 and not result.endswith('\n'):
79+
result += ' '
80+
result += line.rstrip('\n')
81+
result = re.sub(r"\[(.*?)\]\((.*?)\)", r"\1 <\2>", result) # Links transformation
82+
result = result.replace("`", "\"").replace("\*", "*")
83+
return result.strip()
84+
85+
86+
def collect_descriptions(files):
87+
descriptions = {}
88+
for name, file in files.items():
89+
started = False
90+
desc = []
91+
with file.open("r", encoding="utf-8") as readme:
92+
for line in readme:
93+
if line.startswith('##'):
94+
if not started:
95+
started = True
96+
continue
97+
else:
98+
break
99+
if started:
100+
desc.append(line)
101+
desc = convert(desc)
102+
if desc != '':
103+
descriptions[name] = desc
104+
else:
105+
logging.warning('No description found in {} file. '
106+
'Check compliance with the OMZ Contribution Guide.'.format(file))
107+
return descriptions
108+
109+
110+
def get_models_from_configs(directory):
111+
yaml = ruamel.yaml.YAML()
112+
yaml.preserve_quotes = True
113+
models = {}
114+
model_configs = directory.glob('**/model.yml')
115+
for model in model_configs:
116+
with model.open("r", encoding="utf-8") as file:
117+
models[model.parent.name] = (model, yaml.load(file))
118+
if not models[model.parent.name][1]:
119+
logging.error("File {} is empty. It will be ignored.".format(model))
120+
del models[model.parent.name]
121+
122+
return models
123+
124+
125+
def update_model_descriptions(models, descriptions, mode):
126+
update_models = []
127+
missed_models = []
128+
for name, desc in descriptions.items():
129+
model = models.get(name, None)
130+
if model is None:
131+
logging.error('For description file {}.md no model found'.format(name))
132+
missed_models.append(name)
133+
continue
134+
if not model[1].get('description', None):
135+
logging.error('No description found in {} for {} model'.format(model[0], name))
136+
missed_models.append(name)
137+
continue
138+
139+
model = model[1]
140+
if model.get('description', '') != desc:
141+
if mode == 'update':
142+
model['description'] = FoldedScalarString(desc)
143+
else:
144+
logging.debug('Found diff for {} model'.format(name))
145+
logging.debug('\n{:12s}{}\n\tvs\n{:12s}{}'
146+
.format('In config:', model['description'], 'In readme:', desc))
147+
update_models.append(name)
148+
if mode == 'update':
149+
msg = 'Description updated for {} models, missed for {} models.'
150+
msg_model_list = 'UPDATED:\n\t{}'
151+
else:
152+
msg = 'Description differs for {} models, missed for {} models.'
153+
msg_model_list = 'DIFFERENCE:\n\t{}'
154+
logging.info(msg.format(len(update_models), len(missed_models)))
155+
if len(update_models) > 0:
156+
logging.info(msg_model_list.format("\n\t".join(update_models)))
157+
if len(missed_models) > 0:
158+
logging.info('FAILED:\n\t{}'.format("\n\t".join(missed_models)))
159+
return update_models
160+
161+
162+
def update_model_configs(models, descriptions, mode):
163+
diffs = update_model_descriptions(models, descriptions, mode)
164+
if mode == 'update':
165+
for name in diffs:
166+
model = models[name]
167+
yaml = ruamel.yaml.YAML()
168+
yaml.indent(mapping=2, sequence=4, offset=2)
169+
yaml.width = 80
170+
with model[0].open("w", encoding="utf-8") as file:
171+
yaml.dump(model[1], file)
172+
173+
174+
def main():
175+
args = parse()
176+
logging.basicConfig(level=getattr(logging, args.log_level.upper()), format='%(levelname)s: %(message)s')
177+
178+
ignored_files = ('index.md',)
179+
descriptions = collect_descriptions(collect_readme(args.model_dir, ignored_files))
180+
models = get_models_from_configs(args.model_dir)
181+
update_model_configs(models, descriptions, args.mode)
182+
183+
184+
if __name__ == '__main__':
185+
main()

ci/get-jobs-for-changes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22

33
# Copyright (c) 2019 Intel Corporation
44
#

ci/requirements-ac-test.txt

+37-21
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1-
atomicwrites==1.3.0
1+
# use update-requirements.py to update this file
2+
3+
atomicwrites==1.3.0 # via -r tools/accuracy_checker/requirements-test.in
24
attrs==19.3.0 # via pytest
3-
editdistance==0.5.3
4-
importlib-metadata==1.5.0 # via pluggy, pytest
5+
cycler==0.10.0 # via matplotlib
6+
decorator==4.4.2 # via networkx
7+
editdistance==0.5.3 # via -r tools/accuracy_checker/requirements.in
8+
imageio==2.8.0 # via scikit-image
9+
importlib-metadata==1.6.0 # via pluggy, pytest
510
joblib==0.14.1 # via scikit-learn
11+
kiwisolver==1.1.0 # via matplotlib
12+
matplotlib==3.0.3 # via scikit-image
613
more-itertools==8.2.0 # via pytest
7-
nibabel==3.0.1
8-
numpy==1.17.5 # via nibabel, scikit-learn, scipy
9-
packaging==20.1 # via pytest
14+
networkx==2.4 # via scikit-image
15+
nibabel==3.0.2 # via -r tools/accuracy_checker/requirements.in
16+
numpy==1.17.5 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, nibabel, pywavelets, scikit-learn, scipy
17+
packaging==20.3 # via pytest
1018
pathlib2==2.3.5 # via pytest
11-
pillow==7.0.0
19+
pillow==7.1.1 # via -r tools/accuracy_checker/requirements.in, imageio, scikit-image
1220
pluggy==0.13.1 # via pytest
13-
py-cpuinfo==4.0.0
21+
py-cpuinfo==4.0.0 # via -r tools/accuracy_checker/requirements.in
1422
py==1.8.1 # via pytest
15-
pyparsing==2.4.6 # via packaging
16-
pytest-mock==2.0.0
17-
pytest==5.3.5
18-
pyyaml==5.3 # via yamlloader
19-
scikit-learn==0.22.1
20-
scipy==1.4.1
21-
sentencepiece==0.1.85
22-
shapely==1.7.0
23-
six==1.14.0 # via packaging, pathlib2
24-
tqdm==4.42.1
25-
wcwidth==0.1.8 # via pytest
26-
yamlloader==0.5.5
27-
zipp==1.1.0 # via importlib-metadata
23+
pydicom==1.4.2 # via -r tools/accuracy_checker/requirements.in
24+
pyparsing==2.4.7 # via matplotlib, packaging
25+
pytest-mock==2.0.0 # via -r tools/accuracy_checker/requirements-test.in
26+
pytest==5.4.1 # via -r tools/accuracy_checker/requirements-test.in, pytest-mock
27+
python-dateutil==2.8.1 # via matplotlib
28+
pywavelets==1.1.1 # via scikit-image
29+
pyyaml==5.3.1 # via -r tools/accuracy_checker/requirements-core.in, yamlloader
30+
scikit-image==0.15.0 # via -r tools/accuracy_checker/requirements.in
31+
scikit-learn==0.22.2.post1 # via -r tools/accuracy_checker/requirements.in
32+
scipy==1.4.1 # via -r tools/accuracy_checker/requirements.in, scikit-image, scikit-learn
33+
sentencepiece==0.1.85 # via -r tools/accuracy_checker/requirements.in
34+
shapely==1.7.0 # via -r tools/accuracy_checker/requirements.in
35+
six==1.14.0 # via packaging, pathlib2, python-dateutil
36+
tokenizers==0.7 # via -r tools/accuracy_checker/requirements.in
37+
tqdm==4.45.0 # via -r tools/accuracy_checker/requirements.in
38+
wcwidth==0.1.9 # via pytest
39+
yamlloader==0.5.5 # via -r tools/accuracy_checker/requirements.in
40+
zipp==1.2.0 # via importlib-metadata
41+
42+
# The following packages are considered to be unsafe in a requirements file:
43+
# setuptools

ci/requirements-ac.txt

+30-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
editdistance==0.5.3
1+
# use update-requirements.py to update this file
2+
3+
cycler==0.10.0 # via matplotlib
4+
decorator==4.4.2 # via networkx
5+
editdistance==0.5.3 # via -r tools/accuracy_checker/requirements.in
6+
imageio==2.8.0 # via scikit-image
27
joblib==0.14.1 # via scikit-learn
3-
nibabel==3.0.1
4-
numpy==1.17.5 # via nibabel, scikit-learn, scipy
5-
pillow==7.0.0
6-
py-cpuinfo==4.0.0
7-
pyyaml==5.3 # via yamlloader
8-
scikit-learn==0.22.1
9-
scipy==1.4.1
10-
sentencepiece==0.1.85
11-
shapely==1.7.0
12-
tqdm==4.42.1
13-
yamlloader==0.5.5
8+
kiwisolver==1.1.0 # via matplotlib
9+
matplotlib==3.0.3 # via scikit-image
10+
networkx==2.4 # via scikit-image
11+
nibabel==3.0.2 # via -r tools/accuracy_checker/requirements.in
12+
numpy==1.17.5 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, nibabel, pywavelets, scikit-learn, scipy
13+
pillow==7.1.1 # via -r tools/accuracy_checker/requirements.in, imageio, scikit-image
14+
py-cpuinfo==4.0.0 # via -r tools/accuracy_checker/requirements.in
15+
pydicom==1.4.2 # via -r tools/accuracy_checker/requirements.in
16+
pyparsing==2.4.7 # via matplotlib
17+
python-dateutil==2.8.1 # via matplotlib
18+
pywavelets==1.1.1 # via scikit-image
19+
pyyaml==5.3.1 # via -r tools/accuracy_checker/requirements-core.in, yamlloader
20+
scikit-image==0.15.0 # via -r tools/accuracy_checker/requirements.in
21+
scikit-learn==0.22.2.post1 # via -r tools/accuracy_checker/requirements.in
22+
scipy==1.4.1 # via -r tools/accuracy_checker/requirements.in, scikit-image, scikit-learn
23+
sentencepiece==0.1.85 # via -r tools/accuracy_checker/requirements.in
24+
shapely==1.7.0 # via -r tools/accuracy_checker/requirements.in
25+
six==1.15.0 # via python-dateutil
26+
tokenizers==0.7 # via -r tools/accuracy_checker/requirements.in
27+
tqdm==4.45.0 # via -r tools/accuracy_checker/requirements.in
28+
yamlloader==0.5.5 # via -r tools/accuracy_checker/requirements.in
29+
30+
# The following packages are considered to be unsafe in a requirements file:
31+
# setuptools

0 commit comments

Comments
 (0)