Skip to content

Commit 1f25cd9

Browse files
author
Anna Grebneva
authored
AC: Added processed_image_info input type (#3298)
* Added processed_image_info input type * Updated docs
1 parent f5b5986 commit 1f25cd9

14 files changed

+48
-12
lines changed

tools/accuracy_checker/openvino/tools/accuracy_checker/config/config_validator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ def type(self):
369369

370370
class InputField(BaseField):
371371
INPUTS_TYPES = (
372-
'CONST_INPUT', 'INPUT', 'IMAGE_INFO', 'ORIG_IMAGE_INFO', 'LSTM_INPUT', 'IGNORE_INPUT', 'SCALE_FACTOR'
372+
'CONST_INPUT', 'INPUT', 'IMAGE_INFO', 'ORIG_IMAGE_INFO', 'PROCESSED_IMAGE_INFO', 'LSTM_INPUT', 'IGNORE_INPUT',
373+
'SCALE_FACTOR'
373374
)
374375
LAYOUT_TYPES = ('NCHW', 'NHWC', 'NCWH', 'NWHC')
375376
PRECISIONS = ('FP32', 'FP16', 'U8', 'U16', 'I8', 'I16', 'I32', 'I64')

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/caffe_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Each input description should has following info:
2020
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
2121
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
2222
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
23+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
2324
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
2425
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.
2526
* `IGNORE_INPUT` - input which should be stayed empty during evaluation.

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/dlsdk_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Each input description should has following info:
5656
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
5757
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
5858
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
59+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
5960
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
6061
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.
6162
* `LSTM_INPUT` - input which should be filled by hidden state from previous iteration. The hidden state layer name should be provided via `value` parameter.

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/gapi_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Each input description should has following info:
2121
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
2222
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
2323
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
24+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
2425
* `IGNORE_INPUT` - input which should be stayed empty during evaluation.
2526
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.
2627
* `shape` - shape of input layer described as comma-separated of all dimensions size except batch size.

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
'boolean': np.uint8
8181
}
8282

83-
INPUT_TYPES_WITHOUT_VALUE = ['IMAGE_INFO', 'ORIG_IMAGE_INFO', 'IGNORE_INPUT', 'LSTM_INPUT', 'SCALE_FACTOR']
83+
INPUT_TYPES_WITHOUT_VALUE = ['IMAGE_INFO', 'ORIG_IMAGE_INFO', 'PROCESSED_IMAGE_INFO', 'IGNORE_INPUT', 'LSTM_INPUT',
84+
'SCALE_FACTOR']
8485

8586

8687
class InputFeeder:
@@ -116,9 +117,10 @@ def configure(self, inputs_config, precisions_list, layouts):
116117
if not self.dummy:
117118
parsing_results = self._parse_inputs_config(inputs_config, self.default_layout, precisions_list, layouts)
118119
self.const_inputs, self.non_constant_inputs, self.inputs_mapping = parsing_results[:3]
119-
self.image_info_inputs, self.orig_image_info_inputs, self.scale_factor_inputs = parsing_results[3:6]
120-
self.lstm_inputs = parsing_results[6]
121-
self.ignore_inputs, self.layouts_mapping, self.precision_mapping, self.inputs_config = parsing_results[7:]
120+
(self.image_info_inputs, self.orig_image_info_inputs, self.processed_image_info_inputs,
121+
self.scale_factor_inputs) = parsing_results[3:7]
122+
self.lstm_inputs = parsing_results[7]
123+
self.ignore_inputs, self.layouts_mapping, self.precision_mapping, self.inputs_config = parsing_results[8:]
122124
if not self.non_constant_inputs:
123125
raise ConfigError('Network should contain at least one layer for setting variable data.')
124126

@@ -147,8 +149,16 @@ def prepare_scale_factor(image_meta):
147149
return [[meta['scale_y'], meta['scale_x']] for meta in image_meta]
148150
return [[1, 1] for _ in image_meta]
149151

150-
meta_batch = extract_image_representations(data_representation_batch, meta_only=True)
152+
data_batch, meta_batch = extract_image_representations(data_representation_batch, meta_only=False)
151153
image_infos = {}
154+
if self.processed_image_info_inputs:
155+
image_info_data = [np.shape(data) for data in data_batch]
156+
image_infos = {
157+
processed_image_info_input:
158+
prepare_image_info(image_info_data, processed_image_info_input, False)
159+
for processed_image_info_input in self.processed_image_info_inputs
160+
}
161+
return image_infos
152162
im_info_resolved = False
153163
if 'image_info' in meta_batch[0]:
154164
image_info_data = [meta['image_info'] for meta in meta_batch]
@@ -187,7 +197,10 @@ def match_by_regex(data, identifiers, input_regex):
187197

188198
filled_inputs = {}
189199
check_regex = True
190-
if self.image_info_inputs or self.orig_image_info_inputs or self.scale_factor_inputs:
200+
if (
201+
self.image_info_inputs or self.orig_image_info_inputs or
202+
self.processed_image_info_inputs or self.scale_factor_inputs
203+
):
191204
image_info_inputs = self._fill_image_info_inputs(data_representation_batch)
192205
filled_inputs = {**image_info_inputs}
193206
for idx, input_layer in enumerate(self.non_constant_inputs):
@@ -256,7 +269,10 @@ def match_by_regex(data, identifiers, input_regex, templates):
256269
filled_inputs = {}
257270
filled_template = {}
258271
check_regex = True
259-
if self.image_info_inputs or self.orig_image_info_inputs or self.scale_factor_inputs:
272+
if (
273+
self.image_info_inputs or self.orig_image_info_inputs or
274+
self.processed_image_info_inputs or self.scale_factor_inputs
275+
):
260276
image_info_inputs = self._fill_image_info_inputs(data_representation_batch)
261277
filled_inputs = {**image_info_inputs}
262278
for idx, input_layer in enumerate(self.non_constant_inputs):
@@ -339,6 +355,7 @@ def _parse_inputs_config(self, inputs_entry, default_layout='NCHW', precisions_l
339355
precisions = {}
340356
image_info_inputs = []
341357
orig_image_info_inputs = []
358+
processed_image_info_inputs = []
342359
lstm_inputs = []
343360
ignore_inputs = []
344361
scale_factor_inputs = []
@@ -349,8 +366,8 @@ def _parse_inputs_config(self, inputs_entry, default_layout='NCHW', precisions_l
349366
raise ConfigError('network does not contain input "{}"'.format(name))
350367
if input_['type'] in INPUT_TYPES_WITHOUT_VALUE:
351368
self._configure_inputs_without_value(
352-
input_, image_info_inputs, orig_image_info_inputs, scale_factor_inputs, lstm_inputs, ignore_inputs,
353-
precision_info, precisions)
369+
input_, image_info_inputs, orig_image_info_inputs, processed_image_info_inputs, scale_factor_inputs,
370+
lstm_inputs, ignore_inputs, precision_info, precisions)
354371
continue
355372

356373
value = input_.get('value')
@@ -376,7 +393,8 @@ def _parse_inputs_config(self, inputs_entry, default_layout='NCHW', precisions_l
376393

377394
all_config_inputs = (
378395
config_non_constant_inputs + list(constant_inputs.keys()) +
379-
image_info_inputs + lstm_inputs + orig_image_info_inputs + ignore_inputs + scale_factor_inputs
396+
image_info_inputs + lstm_inputs + orig_image_info_inputs + ignore_inputs + scale_factor_inputs +
397+
processed_image_info_inputs
380398
)
381399
not_config_inputs = [input_layer for input_layer in self.network_inputs if input_layer not in all_config_inputs]
382400
if config_non_constant_inputs and not_config_inputs:
@@ -394,6 +412,7 @@ def _parse_inputs_config(self, inputs_entry, default_layout='NCHW', precisions_l
394412
non_constant_inputs_mapping or None,
395413
image_info_inputs,
396414
orig_image_info_inputs,
415+
processed_image_info_inputs,
397416
scale_factor_inputs,
398417
lstm_inputs,
399418
ignore_inputs,
@@ -404,7 +423,7 @@ def _parse_inputs_config(self, inputs_entry, default_layout='NCHW', precisions_l
404423

405424
def _configure_inputs_without_value(
406425
self, input_config, image_info_inputs,
407-
orig_image_info_inputs, scale_factor_inputs, lstm_inputs, ignore_inputs,
426+
orig_image_info_inputs, processed_image_info_inputs, scale_factor_inputs, lstm_inputs, ignore_inputs,
408427
precision_info, precisions):
409428
name = input_config['name']
410429
if input_config['type'] == 'IMAGE_INFO':
@@ -415,6 +434,10 @@ def _configure_inputs_without_value(
415434
orig_image_info_inputs.append(name)
416435
self.get_layer_precision(input_config, name, precision_info, precisions)
417436

437+
if input_config['type'] == 'PROCESSED_IMAGE_INFO':
438+
processed_image_info_inputs.append(name)
439+
self.get_layer_precision(input_config, name, precision_info, precisions)
440+
418441
if input_config['type'] == 'SCALE_FACTOR':
419442
scale_factor_inputs.append(name)
420443
self.get_layer_precision(input_config, name, precision_info, precisions)

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/mxnet_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Each input description should has following info:
1616
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
1717
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
1818
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
19+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
1920
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
2021
* `IGNORE_INPUT` - input which should be stayed empty during evaluation.
2122
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/onnx_runtime_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Each input description should has following info:
2121
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
2222
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
2323
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
24+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
2425
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
2526
* `IGNORE_INPUT` - input which should be stayed empty during evaluation.
2627
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/opencv_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Each input description should has following info:
1515
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
1616
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
1717
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
18+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
1819
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
1920
* `IGNORE_INPUT` - input which should be stayed empty during evaluation.
2021
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/openvino_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Each input description should has following info:
5656
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
5757
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
5858
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
59+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
5960
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
6061
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.
6162
* `LSTM_INPUT` - input which should be filled by hidden state from previous iteration. The hidden state layer name should be provided via `value` parameter.

tools/accuracy_checker/openvino/tools/accuracy_checker/launcher/pdpd_launcher_readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Each input description should has following info:
1818
* `CONST_INPUT` - input will be filled using constant provided in config. It also requires to provide `value`.
1919
* `IMAGE_INFO` - specific key for setting information about input shape to layer (used in Faster RCNN based topologies). You do not need to provide `value`, because it will be calculated in runtime. Format value is list with `N` elements of the form `[H, W, S]`, where `N` is batch size, `H` - original image height, `W` - original image width, `S` - scale of original image (default 1).
2020
* `ORIG_IMAGE_INFO` - specific key for setting information about original image size before preprocessing.
21+
* `PROCESSED_IMAGE_INFO` - specific key for setting information about input size after preprocessing.
2122
* `SCALE_FACTOR` - specific key for setting information about image scale factor defined as `[SCALE_Y, SCALE_X]`, where `SCALE_Y` = `<resized_image_height>/<original_image_height`, `SCALE_X` = `<resized_image_width> / <original_image_width>`
2223
* `IGNORE_INPUT` - input which should be stayed empty during evaluation.
2324
* `INPUT` - network input for main data stream (e. g. images). If you have several data inputs, you should provide regular expression for identifier as `value` for specifying which one data should be provided in specific input.

0 commit comments

Comments
 (0)