Skip to content

Commit 065dfdd

Browse files
authored
AC: fix video background matting for ov2.0 (#3290)
1 parent 55e8b3c commit 065dfdd

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ...adapters import create_adapter
2222
from ...config import ConfigError
2323
from ...launcher.input_feeder import InputFeeder
24-
from ...utils import contains_all, extract_image_representations
24+
from ...utils import contains_all, extract_image_representations, postprocess_output_name
2525

2626

2727
class SequentialBackgroundMatting(BaseCustomEvaluator):
@@ -109,7 +109,10 @@ def reset_rnn_inputs(self, batch_size):
109109
for _ in range(batch_size):
110110
zeros_lstm_inputs = {}
111111
for lstm_input_name in self.launcher.lstm_inputs.keys():
112-
shape = self.model.network.input_info[lstm_input_name].input_data.shape
112+
if hasattr(self.model.network, 'input_info'):
113+
shape = self.model.network.input_info[lstm_input_name].input_data.shape
114+
else:
115+
shape = self.model.inputs[lstm_input_name].shape
113116
zeros_lstm_inputs[lstm_input_name] = np.zeros(shape, dtype=np.float32)
114117
output.append(zeros_lstm_inputs)
115118
return output
@@ -119,7 +122,7 @@ def set_rnn_inputs(self, outputs):
119122
for output in outputs:
120123
batch_rnn_inputs = {}
121124
for input_name, output_name in self.launcher.lstm_inputs.items():
122-
batch_rnn_inputs[input_name] = output[output_name]
125+
batch_rnn_inputs[input_name] = output[postprocess_output_name(output_name, output)]
123126
result.append(batch_rnn_inputs)
124127
return result
125128

@@ -131,4 +134,4 @@ def predict(self, identifiers, input_data):
131134

132135
class OpenVINOModelSequentialBackgroundMattingModel(BaseOpenVINOModel):
133136
def predict(self, identifiers, input_data):
134-
return self.exec_network.infer(input_data)
137+
return self.infer(input_data)

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,8 @@ def async_mode(self, flag):
323323

324324
def get_async_requests(self):
325325
self._set_nireq()
326-
return [
327-
AsyncInferRequestWrapper(ireq_id, self.exec_network.create_infer_request())
328-
for ireq_id in range(self.num_requests)]
326+
return [AsyncInferRequestWrapper(ireq_id, self.exec_network.create_infer_request())
327+
for ireq_id in range(self.num_requests)]
329328

330329
def _reshape_input(self, shapes, make_dynamic=False):
331330
if hasattr(self, 'exec_network'):
@@ -350,8 +349,7 @@ def reshape_network(network, shapes):
350349
partial_shapes = {}
351350
for name, shape in shapes.items():
352351
p_shape = PartialShape(
353-
[Dimension(d) if not isinstance(d, tuple) else Dimension(d[0], d[1]) for d in shape]
354-
)
352+
[Dimension(d) if not isinstance(d, tuple) else Dimension(d[0], d[1]) for d in shape])
355353
partial_shapes[name] = p_shape
356354
network.reshape(partial_shapes)
357355
return network
@@ -493,8 +491,7 @@ def _set_device_config(self, device_config):
493491
ov_set_config(self.ie_core, dict(value), device=key)
494492
else:
495493
warnings.warn(
496-
f'Configuration for {key} will be skipped as device is not listed in evaluation device'
497-
)
494+
f'Configuration for {key} will be skipped as device is not listed in evaluation device')
498495
else:
499496
warnings.warn('Option {key}: {value} will be skipped because device to which it should be '
500497
'applied is not specified or option is not a dict-like'.format(key=key, value=value))
@@ -725,8 +722,11 @@ def inputs_info_for_meta(self, inputs=None):
725722
return {layer_name: np.shape(data) for layer_name, data in inputs.items()}
726723
return {
727724
layer_name: parse_partial_shape(layer.get_partial_shape()) for layer_name, layer in self.inputs.items()
728-
if layer_name not in self.const_inputs + self.image_info_inputs
729-
}
725+
if layer_name not in self.const_inputs + self.image_info_inputs}
726+
727+
@property
728+
def lstm_inputs(self):
729+
return self._lstm_inputs
730730

731731
def initialize_undefined_shapes(self, input_data, template_shapes=None):
732732
if self.dynamic_shapes_policy in ['default', 'dynamic']:

tools/accuracy_checker/openvino/tools/accuracy_checker/metrics/background_matting.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
convolve = UnsupportedPackage('scipy', err.msg)
3434

3535

36-
3736
class BaseBackgroundMattingMetrics(PerImageEvaluationMetric):
3837
annotation_types = (BackgroundMattingAnnotation,)
3938
prediction_types = (BackgroundMattingPrediction,)
@@ -86,7 +85,7 @@ def configure(self):
8685

8786
@classmethod
8887
def get_common_meta(cls):
89-
return {'target': 'higher-worse'}
88+
return {'target': 'higher-worse', 'scale': 1, 'postfix': ' '}
9089

9190

9291
class MeanOfAbsoluteDifference(BaseBackgroundMattingMetrics):

0 commit comments

Comments
 (0)