Skip to content

Commit b56806f

Browse files
authored
AC: minor fixes (#2932)
1 parent 4255590 commit b56806f

File tree

7 files changed

+39
-27
lines changed

7 files changed

+39
-27
lines changed

tools/accuracy_checker/openvino/tools/accuracy_checker/argparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def add_openvino_specific_args(parser):
350350
)
351351
openvino_specific_args.add_argument(
352352
'--use_new_api', type=cast_to_bool, help='switch to processing using OpenVINO 2.0 API', required=False,
353-
default=False
353+
default=None
354354
)
355355

356356

tools/accuracy_checker/openvino/tools/accuracy_checker/config/config_reader.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@
6565
}
6666

6767
LIST_ENTRIES_PATHS = {
68-
'model': 'models',
69-
'weights': 'models',
70-
'color_coeff': ['model_attributes', 'models'],
71-
'caffe_model': 'models',
72-
'caffe_weights': 'models',
73-
'tf_model': 'models',
74-
'tf_meta': 'models',
75-
'mxnet_weights': 'models',
76-
'onnx_model': 'models',
77-
'kaldi_model': 'models',
78-
'saved_model_dir': 'models',
79-
'params': 'models'
68+
'model': 'models',
69+
'weights': 'models',
70+
'color_coeff': ['model_attributes', 'models'],
71+
'caffe_model': 'models',
72+
'caffe_weights': 'models',
73+
'tf_model': 'models',
74+
'tf_meta': 'models',
75+
'mxnet_weights': 'models',
76+
'onnx_model': 'models',
77+
'kaldi_model': 'models',
78+
'saved_model_dir': 'models',
79+
'params': 'models'
8080
}
8181

8282
COMMAND_LINE_ARGS_AS_ENV_VARS = {
@@ -190,7 +190,7 @@ def _check_module_config(config):
190190
config_checker_func = config_checkers.get(eval_mode)
191191
if config_checker_func is None:
192192
raise ConfigError(
193-
'Accuracy Checker {} mode is not supported. Please select between evaluations and models.'. format(
193+
'Accuracy Checker {} mode is not supported. Please select between evaluations and models.'.format(
194194
eval_mode))
195195
config_checker_func(config)
196196

@@ -676,8 +676,8 @@ def filter_modules(config, target_devices, args):
676676

677677

678678
def process_config(
679-
config_item, entries_paths, args, dataset_identifier='datasets',
680-
launchers_identifier='launchers', identifiers_mapping=None, pipeline=False
679+
config_item, entries_paths, args, dataset_identifier='datasets',
680+
launchers_identifier='launchers', identifiers_mapping=None, pipeline=False
681681
):
682682
def process_dataset(datasets_configs):
683683
for datasets_config in datasets_configs:
@@ -849,7 +849,7 @@ def _async_evaluation_args(launcher_entry):
849849

850850
if launcher_entry['framework'].lower() not in ['dlsdk', 'openvino']:
851851
return launcher_entry
852-
if 'use_new_api' in arguments:
852+
if 'use_new_api' in arguments and arguments.use_new_api is not None:
853853
if launcher_entry['framework'].lower() == 'dlsdk' and arguments.use_new_api:
854854
launcher_entry['framework'] = 'openvino'
855855
elif launcher_entry['framework'].lower() == 'openvino' and not arguments.use_new_api:
@@ -912,8 +912,8 @@ def merge_device_configs(launcher_entry, device_config_file):
912912
if not embedded_device_config:
913913
embedded_device_config = external_device_config
914914
elif (
915-
not isinstance(next(iter(external_device_config.values())), dict)
916-
and not isinstance(next(iter(embedded_device_config.values())), dict)
915+
not isinstance(next(iter(external_device_config.values())), dict)
916+
and not isinstance(next(iter(embedded_device_config.values())), dict)
917917
):
918918
embedded_device_config.update(external_device_config)
919919
else:

tools/accuracy_checker/openvino/tools/accuracy_checker/evaluators/custom_evaluators/base_models.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ def automatic_model_search(self, network_info):
164164
if len(model_list) > 1:
165165
raise ConfigError('Several suitable models for {} found'.format(self.default_model_suffix))
166166
model = model_list[0]
167-
accepted_suffixes = ['.blob', '.xml']
167+
accepted_suffixes = ['.blob', '.xml', '.onnx']
168168
if model.suffix not in accepted_suffixes:
169169
raise ConfigError('Models with following suffixes are allowed: {}'.format(accepted_suffixes))
170170
print_info('{} - Found model: {}'.format(self.default_model_suffix, model))
171-
if model.suffix == '.blob':
171+
if model.suffix in ['.blob', '.onnx']:
172172
return model, None
173173
weights = get_path(network_info.get('weights', model.parent / model.name.replace('xml', 'bin')))
174174
accepted_weights_suffixes = ['.bin']
@@ -200,11 +200,14 @@ def load_model(self, network_info, launcher, log=False):
200200
model, weights = launcher.convert_model(network_info)
201201
else:
202202
model, weights = self.automatic_model_search(network_info)
203-
if weights is not None:
204-
self.network = launcher.read_network(str(model), str(weights))
205-
self.load_network(self.network, launcher)
206-
else:
203+
if weights is None and model.suffix != '.onnx':
207204
self.exec_network = launcher.ie_core.import_network(str(model))
205+
else:
206+
if weights:
207+
self.network = launcher.read_network(str(model), str(weights))
208+
else:
209+
self.network = launcher.ie_core.read_network(str(model))
210+
self.load_network(self.network, launcher)
208211
self.set_input_and_output()
209212
if log:
210213
self.print_input_output_info()

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/dlsdk_launcher.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,10 @@ def load_ir(self, xml_path, bin_path, log=False):
656656

657657
def read_network(self, model, weights):
658658
if 'read_network' in ie.IECore.__dict__:
659-
network = self.ie_core.read_network(model=str(model), weights=str(weights))
659+
if weights is None:
660+
network = self.ie_core.read_network(model=str(model))
661+
else:
662+
network = self.ie_core.read_network(model=str(model), weights=str(weights))
660663
else:
661664
network = ie.IENetwork(model=str(model), weights=str(weights))
662665
return network

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/dlsdk_launcher_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ def automatic_model_search(model_name, model_cfg, weights_cfg, model_type=None):
382382
'paddle': 'pdmodel',
383383
'tf': 'pb'
384384
}
385+
385386
def get_model_by_suffix(model_name, model_dir, suffix):
386387
model_list = list(Path(model_dir).glob('{}.{}'.format(model_name, suffix)))
387388
if not model_list:

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/input_feeder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
'NDHWC': [0, 1, 2, 3, 4],
3535
'NDCWH': [0, 1, 4, 3, 2],
3636
'NCHWD': [0, 2, 3, 4, 1],
37+
'NHWDC': [0, 2, 3, 1, 4],
38+
'NHWCD': [0, 2, 3, 4, 1],
3739
'NC': [0, 1],
3840
'CN': [1, 0],
3941
'CNH': [1, 0, 2],

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/openvino_launcher.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,10 @@ def load_ir(self, xml_path, bin_path, log=False):
602602
self.try_to_set_default_layout()
603603

604604
def read_network(self, model, weights):
605-
network = self.ie_core.read_model(model=str(model), weights=str(weights))
605+
if weights is not None:
606+
network = self.ie_core.read_model(model=str(model), weights=str(weights))
607+
else:
608+
network = self.ie_core.read_model(model=str(model))
606609
return network
607610

608611
def inputs_info_for_meta(self):

0 commit comments

Comments
 (0)