[POT] IEEngine output data order (#10527)

* IEEngine fix for multiply-output nets

* Update docstrings and docs

* Codestyle changes

* Update docs

* Update docstring

* Pylint
This commit is contained in:
Nikita Malinin 2022-02-20 09:44:04 +03:00 committed by GitHub
parent 5c7be85435
commit a312dd4a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View File

@ -222,14 +222,13 @@ This class support inference in synchronous and asynchronous modes and can be re
with some modifications, e.g. in case of custom post-processing of inference results.
The following methods can be overridden in subclasses:
- `postprocess_output(outputs, metadata)` - processes raw model output using the image metadata obtained during
data loading.<br><br>
- `postprocess_output(outputs, metadata)` - Processes model output data using the image metadata obtained during data loading.<br><br>
*Parameters*
- `outputs` - raw output of the model.
- `outputs` - dictionary of output data per output name.
- `metadata` - information about the data used for inference.
*Return*
- post-processed model output
- list of the output data in an order expected by the accuracy metric if any is used
`IEEngine` supports data returned by `DataLoader` in the format:
```

View File

@ -187,12 +187,13 @@ class SegmentationEngine(IEEngine):
"""
Processes model raw output for future metric and loss calculation.
Uses image metadata that can be passed using dataloader.
:param outputs: network infer result in format of numpy ndarray (batch x image shape)
:param outputs: network infer result in the format of dictionary numpy ndarray
by layer name (batch x image shape)
:param metadata: dictionary of image metadata
:return: processed numpy ndarray with the same shape as the original output
"""
processed_outputs = []
for output, meta in zip(outputs, metadata):
for output, meta in zip(outputs.values(), metadata):
# Resize to bounding box size and extend to mask size
low = meta['bbox'][0]
high = meta['bbox'][1]

View File

@ -143,8 +143,12 @@ class IEEngine(Engine):
@staticmethod
def postprocess_output(outputs, _metadata):
""" Processes raw model output using the image metadata obtained during data loading """
return outputs
""" Processes model output data using the image metadata obtained during data loading
:param outputs: dictionary of output data per output name
:param _metadata: metadata obtained during data loading
:return: list of the output data in an order expected by the accuracy metric if any is used
"""
return list(outputs.values())
def _reset(self):
""" Resets collected statistics """
@ -182,14 +186,12 @@ class IEEngine(Engine):
annotations=batch_annotations)
# Postprocess network output
outputs = process_raw_output(predictions)
output = outputs[self._output_layers[0]]
outputs[self._output_layers[0]] = self.postprocess_output(output, batch_meta)
processed_outputs = process_raw_output(predictions)
outputs = {name: processed_outputs[name] for name in self._output_layers}
logits = self.postprocess_output(outputs, batch_meta)
# Update metrics
if batch_annotations:
# TODO: Create some kind of an order for the correct metric calculation
logits = [outputs[name] for name in self._output_layers] # output_layers are in a random order
self._update_metrics(output=logits, annotations=batch_annotations,
need_metrics_per_sample=need_metrics_per_sample)