[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:
parent
5c7be85435
commit
a312dd4a9f
@ -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.
|
with some modifications, e.g. in case of custom post-processing of inference results.
|
||||||
|
|
||||||
The following methods can be overridden in subclasses:
|
The following methods can be overridden in subclasses:
|
||||||
- `postprocess_output(outputs, metadata)` - processes raw model output using the image metadata obtained during
|
- `postprocess_output(outputs, metadata)` - Processes model output data using the image metadata obtained during data loading.<br><br>
|
||||||
data loading.<br><br>
|
|
||||||
*Parameters*
|
*Parameters*
|
||||||
- `outputs` - raw output of the model.
|
- `outputs` - dictionary of output data per output name.
|
||||||
- `metadata` - information about the data used for inference.
|
- `metadata` - information about the data used for inference.
|
||||||
|
|
||||||
*Return*
|
*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:
|
`IEEngine` supports data returned by `DataLoader` in the format:
|
||||||
```
|
```
|
||||||
|
@ -187,12 +187,13 @@ class SegmentationEngine(IEEngine):
|
|||||||
"""
|
"""
|
||||||
Processes model raw output for future metric and loss calculation.
|
Processes model raw output for future metric and loss calculation.
|
||||||
Uses image metadata that can be passed using dataloader.
|
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
|
:param metadata: dictionary of image metadata
|
||||||
:return: processed numpy ndarray with the same shape as the original output
|
:return: processed numpy ndarray with the same shape as the original output
|
||||||
"""
|
"""
|
||||||
processed_outputs = []
|
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
|
# Resize to bounding box size and extend to mask size
|
||||||
low = meta['bbox'][0]
|
low = meta['bbox'][0]
|
||||||
high = meta['bbox'][1]
|
high = meta['bbox'][1]
|
||||||
|
@ -143,8 +143,12 @@ class IEEngine(Engine):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def postprocess_output(outputs, _metadata):
|
def postprocess_output(outputs, _metadata):
|
||||||
""" Processes raw model output using the image metadata obtained during data loading """
|
""" Processes model output data using the image metadata obtained during data loading
|
||||||
return outputs
|
: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):
|
def _reset(self):
|
||||||
""" Resets collected statistics """
|
""" Resets collected statistics """
|
||||||
@ -182,14 +186,12 @@ class IEEngine(Engine):
|
|||||||
annotations=batch_annotations)
|
annotations=batch_annotations)
|
||||||
|
|
||||||
# Postprocess network output
|
# Postprocess network output
|
||||||
outputs = process_raw_output(predictions)
|
processed_outputs = process_raw_output(predictions)
|
||||||
output = outputs[self._output_layers[0]]
|
outputs = {name: processed_outputs[name] for name in self._output_layers}
|
||||||
outputs[self._output_layers[0]] = self.postprocess_output(output, batch_meta)
|
logits = self.postprocess_output(outputs, batch_meta)
|
||||||
|
|
||||||
# Update metrics
|
# Update metrics
|
||||||
if batch_annotations:
|
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,
|
self._update_metrics(output=logits, annotations=batch_annotations,
|
||||||
need_metrics_per_sample=need_metrics_per_sample)
|
need_metrics_per_sample=need_metrics_per_sample)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user