[MO, nGraph, transforms., ref., python] Support DetectionOutput-8 (#8853)
* Implement MO part for DetectionOutput-8 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement nGraph part for DetectionOutput-8 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement deduction of a number of classes method Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix build Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement nGraph tests to check shape inference for DetectionOutput-8 with deduction of num_classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement attributes tests for DetectionOutput-8 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove DetectionOutput-1 from opset8 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add python bindings for DetectionOutput-8 and tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement downgrading and upgrading transformations for DetectionOutput Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement tests for downgrading and upgrading transformations for DetectionOutput Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Adopt existing reference for DetectionOutput-8 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix DetectionOutput-8 reference Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add tests for DetectionOutput-8 reference Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Finish resolving merge conflict Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix python bindings after re-structuring Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix BOM package list Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix multibox_detection_test Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix python bindings for DetectionOutput-8 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Insert blank line between summary and description for python binding Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply review comments: identation, for loop Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix formatting in python bindings Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix supported_attrs for DetectionOutput from opset1 Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add missed imports for python if_op Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply feedback and fix Win build Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Use the same test suite name for test mixture Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix transformation tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Recover BWDCMP_RTTI for legacy use and remove unused variables in tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove unused variables in type_prop tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Recover legacy referenceDetectionOutput constructor Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix python binding for DetectionOutput Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com>
This commit is contained in:
@@ -38,7 +38,7 @@ from ngraph.opset3.ops import cum_sum as cumsum
|
||||
from ngraph.opset8.ops import deformable_convolution
|
||||
from ngraph.opset1.ops import deformable_psroi_pooling
|
||||
from ngraph.opset1.ops import depth_to_space
|
||||
from ngraph.opset1.ops import detection_output
|
||||
from ngraph.opset8.ops import detection_output
|
||||
from ngraph.opset7.ops import dft
|
||||
from ngraph.opset1.ops import divide
|
||||
from ngraph.opset7.ops import einsum
|
||||
|
||||
@@ -3,41 +3,28 @@
|
||||
|
||||
"""Factory functions for all ngraph ops."""
|
||||
from functools import partial
|
||||
from typing import Callable, Iterable, List, Optional, Set, Union, Tuple
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
import numpy as np
|
||||
from ngraph.exceptions import UserInputError
|
||||
from ngraph.impl import Node, Shape
|
||||
from ngraph.impl.op import Constant, Parameter
|
||||
from ngraph.impl import Node
|
||||
from ngraph.opset_utils import _get_node_factory
|
||||
from ngraph.utils.decorators import binary_op, nameable_op, unary_op
|
||||
from ngraph.utils.decorators import nameable_op
|
||||
from ngraph.utils.input_validation import (
|
||||
assert_list_of_ints,
|
||||
check_valid_attributes,
|
||||
is_non_negative_value,
|
||||
is_positive_value,
|
||||
)
|
||||
from ngraph.utils.node_factory import NodeFactory
|
||||
from ngraph.utils.tensor_iterator_types import (
|
||||
GraphBody,
|
||||
TensorIteratorSliceInputDesc,
|
||||
TensorIteratorMergedInputDesc,
|
||||
TensorIteratorInvariantInputDesc,
|
||||
TensorIteratorBodyOutputDesc,
|
||||
TensorIteratorConcatOutputDesc,
|
||||
)
|
||||
from ngraph.utils.types import (
|
||||
NodeInput,
|
||||
NumericData,
|
||||
NumericType,
|
||||
ScalarData,
|
||||
TensorShape,
|
||||
as_node,
|
||||
as_nodes,
|
||||
get_dtype,
|
||||
get_element_type,
|
||||
get_element_type_str,
|
||||
make_constant_node,
|
||||
)
|
||||
|
||||
_get_node_factory_opset8 = partial(_get_node_factory, "opset8")
|
||||
@@ -141,18 +128,18 @@ def adaptive_max_pool(
|
||||
|
||||
@nameable_op
|
||||
def multiclass_nms(
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
iou_threshold: float = 0.0,
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
nms_eta: float = 1.0,
|
||||
normalized: bool = True
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
iou_threshold: float = 0.0,
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
nms_eta: float = 1.0,
|
||||
normalized: bool = True
|
||||
) -> Node:
|
||||
"""Return a node which performs MulticlassNms.
|
||||
|
||||
@@ -197,19 +184,19 @@ def multiclass_nms(
|
||||
|
||||
@nameable_op
|
||||
def matrix_nms(
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
decay_function: str = "linear",
|
||||
gaussian_sigma: float = 2.0,
|
||||
post_threshold: float = 0.0,
|
||||
normalized: bool = True
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
decay_function: str = "linear",
|
||||
gaussian_sigma: float = 2.0,
|
||||
post_threshold: float = 0.0,
|
||||
normalized: bool = True
|
||||
) -> Node:
|
||||
"""Return a node which performs MatrixNms.
|
||||
|
||||
@@ -281,17 +268,17 @@ def gather(
|
||||
|
||||
@nameable_op
|
||||
def max_pool(
|
||||
data: NodeInput,
|
||||
strides: List[int],
|
||||
dilations: List[int],
|
||||
pads_begin: List[int],
|
||||
pads_end: List[int],
|
||||
kernel_shape: TensorShape,
|
||||
rounding_type: str = "floor",
|
||||
auto_pad: Optional[str] = None,
|
||||
index_element_type: Optional[str] = "i64",
|
||||
axis: Optional[int] = 0,
|
||||
name: Optional[str] = None,
|
||||
data: NodeInput,
|
||||
strides: List[int],
|
||||
dilations: List[int],
|
||||
pads_begin: List[int],
|
||||
pads_end: List[int],
|
||||
kernel_shape: TensorShape,
|
||||
rounding_type: str = "floor",
|
||||
auto_pad: Optional[str] = None,
|
||||
index_element_type: Optional[str] = "i64",
|
||||
axis: Optional[int] = 0,
|
||||
name: Optional[str] = None,
|
||||
) -> Node:
|
||||
"""Perform max pooling operation and return both values and indices of the selected elements.
|
||||
|
||||
@@ -457,7 +444,7 @@ def gather_nd(
|
||||
|
||||
|
||||
def prior_box(
|
||||
layer_shape: Node, image_shape: NodeInput, attrs: dict, name: Optional[str] = None
|
||||
layer_shape: Node, image_shape: NodeInput, attrs: dict, name: Optional[str] = None
|
||||
) -> Node:
|
||||
"""Generate prior boxes of specified sizes and aspect ratios across all dimensions.
|
||||
|
||||
@@ -655,3 +642,138 @@ def nv12_to_rgb(
|
||||
inputs = as_nodes(arg, arg_uv)
|
||||
|
||||
return _get_node_factory_opset8().create("NV12toRGB", inputs)
|
||||
|
||||
|
||||
@nameable_op
|
||||
def detection_output(
|
||||
box_logits: NodeInput,
|
||||
class_preds: NodeInput,
|
||||
proposals: NodeInput,
|
||||
attrs: dict,
|
||||
aux_class_preds: Optional[NodeInput] = None,
|
||||
aux_box_preds: Optional[NodeInput] = None,
|
||||
name: Optional[str] = None,
|
||||
) -> Node:
|
||||
"""Generate the detection output using information on location and confidence predictions.
|
||||
|
||||
@param box_logits: The 2D input tensor with box logits.
|
||||
@param class_preds: The 2D input tensor with class predictions.
|
||||
@param proposals: The 3D input tensor with proposals.
|
||||
@param attrs: The dictionary containing key, value pairs for attributes.
|
||||
@param aux_class_preds: The 2D input tensor with additional class predictions information.
|
||||
@param aux_box_preds: The 2D input tensor with additional box predictions information.
|
||||
@param name: Optional name for the output node.
|
||||
@return Node representing DetectionOutput operation.
|
||||
Available attributes are:
|
||||
* background_label_id The background label id.
|
||||
Range of values: integer value
|
||||
Default value: 0
|
||||
Required: no
|
||||
* top_k Maximum number of results to be kept per batch after NMS step.
|
||||
Range of values: integer value
|
||||
Default value: -1
|
||||
Required: no
|
||||
* variance_encoded_in_target The flag that denotes if variance is encoded in target.
|
||||
Range of values: {False, True}
|
||||
Default value: False
|
||||
Required: no
|
||||
* keep_top_k Maximum number of bounding boxes per batch to be kept after NMS step.
|
||||
Range of values: integer values
|
||||
Default value: None
|
||||
Required: yes
|
||||
* code_type The type of coding method for bounding boxes.
|
||||
Range of values: {'caffe.PriorBoxParameter.CENTER_SIZE',
|
||||
'caffe.PriorBoxParameter.CORNER'}
|
||||
Default value: 'caffe.PriorBoxParameter.CORNER'
|
||||
Required: no
|
||||
* share_location The flag that denotes if bounding boxes are shared among different
|
||||
classes.
|
||||
Range of values: {True, False}
|
||||
Default value: True
|
||||
Required: no
|
||||
* nms_threshold The threshold to be used in the NMS stage.
|
||||
Range of values: floating point value
|
||||
Default value: None
|
||||
Required: yes
|
||||
* confidence_threshold Specifies the minimum confidence threshold for detection boxes to be
|
||||
considered.
|
||||
Range of values: floating point value
|
||||
Default value: 0
|
||||
Required: no
|
||||
* clip_after_nms The flag that denotes whether to perform clip bounding boxes after
|
||||
non-maximum suppression or not.
|
||||
Range of values: {True, False}
|
||||
Default value: False
|
||||
Required: no
|
||||
* clip_before_nms The flag that denotes whether to perform clip bounding boxes before
|
||||
non-maximum suppression or not.
|
||||
Range of values: {True, False}
|
||||
Default value: False
|
||||
Required: no
|
||||
* decrease_label_id The flag that denotes how to perform NMS.
|
||||
Range of values: False - perform NMS like in Caffe*.
|
||||
True - perform NMS like in MxNet*.
|
||||
Default value: False
|
||||
Required: no
|
||||
* normalized The flag that denotes whether input tensors with boxes are normalized.
|
||||
Range of values: {True, False}
|
||||
Default value: False
|
||||
Required: no
|
||||
* input_height The input image height.
|
||||
Range of values: positive integer number
|
||||
Default value: 1
|
||||
Required: no
|
||||
* input_width The input image width.
|
||||
Range of values: positive integer number
|
||||
Default value: 1
|
||||
Required: no
|
||||
* objectness_score The threshold to sort out confidence predictions.
|
||||
Range of values: non-negative float number
|
||||
Default value: 0
|
||||
Required: no
|
||||
Example of attribute dictionary:
|
||||
@code{.py}
|
||||
# just required ones
|
||||
attrs = {
|
||||
'keep_top_k': [1, 2, 3],
|
||||
'nms_threshold': 0.645,
|
||||
}
|
||||
attrs = {
|
||||
'keep_top_k': [1, 2, 3],
|
||||
'nms_threshold': 0.645,
|
||||
'normalized': True,
|
||||
'clip_before_nms': True,
|
||||
'input_height': [32],
|
||||
'input_width': [32],
|
||||
}
|
||||
@endcode
|
||||
Optional attributes which are absent from dictionary will be set with corresponding default.
|
||||
"""
|
||||
requirements = [
|
||||
("background_label_id", False, np.integer, None),
|
||||
("top_k", False, np.integer, None),
|
||||
("variance_encoded_in_target", False, np.bool_, None),
|
||||
("keep_top_k", True, np.integer, None),
|
||||
("code_type", False, np.str_, None),
|
||||
("share_location", False, np.bool_, None),
|
||||
("nms_threshold", True, np.floating, None),
|
||||
("confidence_threshold", False, np.floating, None),
|
||||
("clip_after_nms", False, np.bool_, None),
|
||||
("clip_before_nms", False, np.bool_, None),
|
||||
("decrease_label_id", False, np.bool_, None),
|
||||
("normalized", False, np.bool_, None),
|
||||
("input_height", False, np.integer, is_positive_value),
|
||||
("input_width", False, np.integer, is_positive_value),
|
||||
("objectness_score", False, np.floating, is_non_negative_value),
|
||||
]
|
||||
|
||||
check_valid_attributes("DetectionOutput", attrs, requirements)
|
||||
|
||||
inputs = [box_logits, class_preds, proposals]
|
||||
if aux_class_preds is not None:
|
||||
inputs.append(aux_class_preds)
|
||||
if aux_box_preds is not None:
|
||||
inputs.append(aux_box_preds)
|
||||
inputs = as_nodes(*inputs)
|
||||
|
||||
return _get_node_factory_opset8().create("DetectionOutput", inputs, attrs)
|
||||
|
||||
@@ -38,7 +38,7 @@ from openvino.runtime.opset3.ops import cum_sum as cumsum
|
||||
from openvino.runtime.opset8.ops import deformable_convolution
|
||||
from openvino.runtime.opset1.ops import deformable_psroi_pooling
|
||||
from openvino.runtime.opset1.ops import depth_to_space
|
||||
from openvino.runtime.opset1.ops import detection_output
|
||||
from openvino.runtime.opset8.ops import detection_output
|
||||
from openvino.runtime.opset7.ops import dft
|
||||
from openvino.runtime.opset1.ops import divide
|
||||
from openvino.runtime.opset7.ops import einsum
|
||||
|
||||
@@ -3,41 +3,28 @@
|
||||
|
||||
"""Factory functions for all openvino ops."""
|
||||
from functools import partial
|
||||
from typing import Callable, Iterable, List, Optional, Set, Union, Tuple
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
import numpy as np
|
||||
from openvino.runtime.exceptions import UserInputError
|
||||
from openvino.runtime.impl import Node, Shape
|
||||
from openvino.runtime.impl.op import Constant, Parameter
|
||||
from openvino.runtime.impl import Node
|
||||
from openvino.runtime.opset_utils import _get_node_factory
|
||||
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op
|
||||
from openvino.runtime.utils.decorators import nameable_op
|
||||
from openvino.runtime.utils.input_validation import (
|
||||
assert_list_of_ints,
|
||||
check_valid_attributes,
|
||||
is_non_negative_value,
|
||||
is_positive_value,
|
||||
)
|
||||
from openvino.runtime.utils.node_factory import NodeFactory
|
||||
from openvino.runtime.utils.tensor_iterator_types import (
|
||||
GraphBody,
|
||||
TensorIteratorSliceInputDesc,
|
||||
TensorIteratorMergedInputDesc,
|
||||
TensorIteratorInvariantInputDesc,
|
||||
TensorIteratorBodyOutputDesc,
|
||||
TensorIteratorConcatOutputDesc,
|
||||
)
|
||||
from openvino.runtime.utils.types import (
|
||||
NodeInput,
|
||||
NumericData,
|
||||
NumericType,
|
||||
ScalarData,
|
||||
TensorShape,
|
||||
as_node,
|
||||
as_nodes,
|
||||
get_dtype,
|
||||
get_element_type,
|
||||
get_element_type_str,
|
||||
make_constant_node,
|
||||
)
|
||||
|
||||
_get_node_factory_opset8 = partial(_get_node_factory, "opset8")
|
||||
@@ -141,18 +128,18 @@ def adaptive_max_pool(
|
||||
|
||||
@nameable_op
|
||||
def multiclass_nms(
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
iou_threshold: float = 0.0,
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
nms_eta: float = 1.0,
|
||||
normalized: bool = True
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
iou_threshold: float = 0.0,
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
nms_eta: float = 1.0,
|
||||
normalized: bool = True
|
||||
) -> Node:
|
||||
"""Return a node which performs MulticlassNms.
|
||||
|
||||
@@ -197,19 +184,19 @@ def multiclass_nms(
|
||||
|
||||
@nameable_op
|
||||
def matrix_nms(
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
decay_function: str = "linear",
|
||||
gaussian_sigma: float = 2.0,
|
||||
post_threshold: float = 0.0,
|
||||
normalized: bool = True
|
||||
boxes: NodeInput,
|
||||
scores: NodeInput,
|
||||
sort_result_type: str = "none",
|
||||
sort_result_across_batch: bool = False,
|
||||
output_type: str = "i64",
|
||||
score_threshold: float = 0.0,
|
||||
nms_top_k: int = -1,
|
||||
keep_top_k: int = -1,
|
||||
background_class: int = -1,
|
||||
decay_function: str = "linear",
|
||||
gaussian_sigma: float = 2.0,
|
||||
post_threshold: float = 0.0,
|
||||
normalized: bool = True
|
||||
) -> Node:
|
||||
"""Return a node which performs MatrixNms.
|
||||
|
||||
@@ -281,17 +268,17 @@ def gather(
|
||||
|
||||
@nameable_op
|
||||
def max_pool(
|
||||
data: NodeInput,
|
||||
strides: List[int],
|
||||
dilations: List[int],
|
||||
pads_begin: List[int],
|
||||
pads_end: List[int],
|
||||
kernel_shape: TensorShape,
|
||||
rounding_type: str = "floor",
|
||||
auto_pad: Optional[str] = None,
|
||||
index_element_type: Optional[str] = "i64",
|
||||
axis: Optional[int] = 0,
|
||||
name: Optional[str] = None,
|
||||
data: NodeInput,
|
||||
strides: List[int],
|
||||
dilations: List[int],
|
||||
pads_begin: List[int],
|
||||
pads_end: List[int],
|
||||
kernel_shape: TensorShape,
|
||||
rounding_type: str = "floor",
|
||||
auto_pad: Optional[str] = None,
|
||||
index_element_type: Optional[str] = "i64",
|
||||
axis: Optional[int] = 0,
|
||||
name: Optional[str] = None,
|
||||
) -> Node:
|
||||
"""Perform max pooling operation and return both values and indices of the selected elements.
|
||||
|
||||
@@ -458,7 +445,7 @@ def gather_nd(
|
||||
|
||||
@nameable_op
|
||||
def prior_box(
|
||||
layer_shape: Node, image_shape: NodeInput, attrs: dict, name: Optional[str] = None
|
||||
layer_shape: Node, image_shape: NodeInput, attrs: dict, name: Optional[str] = None
|
||||
) -> Node:
|
||||
"""Generate prior boxes of specified sizes and aspect ratios across all dimensions.
|
||||
|
||||
@@ -656,3 +643,138 @@ def nv12_to_rgb(
|
||||
inputs = as_nodes(arg, arg_uv)
|
||||
|
||||
return _get_node_factory_opset8().create("NV12toRGB", inputs)
|
||||
|
||||
|
||||
@nameable_op
|
||||
def detection_output(
|
||||
box_logits: NodeInput,
|
||||
class_preds: NodeInput,
|
||||
proposals: NodeInput,
|
||||
attrs: dict,
|
||||
aux_class_preds: Optional[NodeInput] = None,
|
||||
aux_box_preds: Optional[NodeInput] = None,
|
||||
name: Optional[str] = None,
|
||||
) -> Node:
|
||||
"""Generate the detection output using information on location and confidence predictions.
|
||||
|
||||
@param box_logits: The 2D input tensor with box logits.
|
||||
@param class_preds: The 2D input tensor with class predictions.
|
||||
@param proposals: The 3D input tensor with proposals.
|
||||
@param attrs: The dictionary containing key, value pairs for attributes.
|
||||
@param aux_class_preds: The 2D input tensor with additional class predictions information.
|
||||
@param aux_box_preds: The 2D input tensor with additional box predictions information.
|
||||
@param name: Optional name for the output node.
|
||||
@return Node representing DetectionOutput operation.
|
||||
Available attributes are:
|
||||
* background_label_id The background label id.
|
||||
Range of values: integer value
|
||||
Default value: 0
|
||||
Required: no
|
||||
* top_k Maximum number of results to be kept per batch after NMS step.
|
||||
Range of values: integer value
|
||||
Default value: -1
|
||||
Required: no
|
||||
* variance_encoded_in_target The flag that denotes if variance is encoded in target.
|
||||
Range of values: {False, True}
|
||||
Default value: False
|
||||
Required: no
|
||||
* keep_top_k Maximum number of bounding boxes per batch to be kept after NMS step.
|
||||
Range of values: integer values
|
||||
Default value: None
|
||||
Required: yes
|
||||
* code_type The type of coding method for bounding boxes.
|
||||
Range of values: {'caffe.PriorBoxParameter.CENTER_SIZE',
|
||||
'caffe.PriorBoxParameter.CORNER'}
|
||||
Default value: 'caffe.PriorBoxParameter.CORNER'
|
||||
Required: no
|
||||
* share_location The flag that denotes if bounding boxes are shared among different
|
||||
classes.
|
||||
Range of values: {True, False}
|
||||
Default value: True
|
||||
Required: no
|
||||
* nms_threshold The threshold to be used in the NMS stage.
|
||||
Range of values: floating point value
|
||||
Default value: None
|
||||
Required: yes
|
||||
* confidence_threshold Specifies the minimum confidence threshold for detection boxes to be
|
||||
considered.
|
||||
Range of values: floating point value
|
||||
Default value: 0
|
||||
Required: no
|
||||
* clip_after_nms The flag that denotes whether to perform clip bounding boxes after
|
||||
non-maximum suppression or not.
|
||||
Range of values: {True, False}
|
||||
Default value: False
|
||||
Required: no
|
||||
* clip_before_nms The flag that denotes whether to perform clip bounding boxes before
|
||||
non-maximum suppression or not.
|
||||
Range of values: {True, False}
|
||||
Default value: False
|
||||
Required: no
|
||||
* decrease_label_id The flag that denotes how to perform NMS.
|
||||
Range of values: False - perform NMS like in Caffe*.
|
||||
True - perform NMS like in MxNet*.
|
||||
Default value: False
|
||||
Required: no
|
||||
* normalized The flag that denotes whether input tensors with boxes are normalized.
|
||||
Range of values: {True, False}
|
||||
Default value: False
|
||||
Required: no
|
||||
* input_height The input image height.
|
||||
Range of values: positive integer number
|
||||
Default value: 1
|
||||
Required: no
|
||||
* input_width The input image width.
|
||||
Range of values: positive integer number
|
||||
Default value: 1
|
||||
Required: no
|
||||
* objectness_score The threshold to sort out confidence predictions.
|
||||
Range of values: non-negative float number
|
||||
Default value: 0
|
||||
Required: no
|
||||
Example of attribute dictionary:
|
||||
@code{.py}
|
||||
# just required ones
|
||||
attrs = {
|
||||
'keep_top_k': [1, 2, 3],
|
||||
'nms_threshold': 0.645,
|
||||
}
|
||||
attrs = {
|
||||
'keep_top_k': [1, 2, 3],
|
||||
'nms_threshold': 0.645,
|
||||
'normalized': True,
|
||||
'clip_before_nms': True,
|
||||
'input_height': [32],
|
||||
'input_width': [32],
|
||||
}
|
||||
@endcode
|
||||
Optional attributes which are absent from dictionary will be set with corresponding default.
|
||||
"""
|
||||
requirements = [
|
||||
("background_label_id", False, np.integer, None),
|
||||
("top_k", False, np.integer, None),
|
||||
("variance_encoded_in_target", False, np.bool_, None),
|
||||
("keep_top_k", True, np.integer, None),
|
||||
("code_type", False, np.str_, None),
|
||||
("share_location", False, np.bool_, None),
|
||||
("nms_threshold", True, np.floating, None),
|
||||
("confidence_threshold", False, np.floating, None),
|
||||
("clip_after_nms", False, np.bool_, None),
|
||||
("clip_before_nms", False, np.bool_, None),
|
||||
("decrease_label_id", False, np.bool_, None),
|
||||
("normalized", False, np.bool_, None),
|
||||
("input_height", False, np.integer, is_positive_value),
|
||||
("input_width", False, np.integer, is_positive_value),
|
||||
("objectness_score", False, np.floating, is_non_negative_value),
|
||||
]
|
||||
|
||||
check_valid_attributes("DetectionOutput", attrs, requirements)
|
||||
|
||||
inputs = [box_logits, class_preds, proposals]
|
||||
if aux_class_preds is not None:
|
||||
inputs.append(aux_class_preds)
|
||||
if aux_box_preds is not None:
|
||||
inputs.append(aux_box_preds)
|
||||
inputs = as_nodes(*inputs)
|
||||
|
||||
return _get_node_factory_opset8().create("DetectionOutput", inputs, attrs)
|
||||
|
||||
@@ -110,7 +110,7 @@ def test_ctc_greedy_decoder(dtype):
|
||||
(np.float64, np.int64, "i64", "i32", False, False),
|
||||
(np.float64, np.int64, "i32", "i64", False, False),
|
||||
(np.float64, np.int64, "i64", "i64", False, False)
|
||||
],)
|
||||
], )
|
||||
def test_ctc_greedy_decoder_seq_len(fp_dtype, int_dtype, int_ci, int_sl, merge_repeated, blank_index):
|
||||
input0_shape = [8, 20, 128]
|
||||
input1_shape = [8]
|
||||
@@ -1093,41 +1093,6 @@ def test_prior_box_clustered(int_dtype, fp_dtype):
|
||||
assert list(node.get_output_shape(0)) == [2, 4332]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_detection_output(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"num_classes": int_dtype(85),
|
||||
"keep_top_k": np.array([64], dtype=int_dtype),
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
}
|
||||
|
||||
box_logits = ov.parameter([4, 8], fp_dtype, "box_logits")
|
||||
class_preds = ov.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ov.parameter([4, 2, 10], fp_dtype, "proposals")
|
||||
aux_class_preds = ov.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ov.parameter([4, 8], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ov.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_type_name() == "DetectionOutput"
|
||||
assert node.get_output_size() == 1
|
||||
assert list(node.get_output_shape(0)) == [1, 1, 256, 7]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
|
||||
111
src/bindings/python/tests/test_ngraph/test_detection_output.py
Normal file
111
src/bindings/python/tests/test_ngraph/test_detection_output.py
Normal file
@@ -0,0 +1,111 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import numpy as np
|
||||
import openvino.runtime.opset8 as ov
|
||||
import pytest
|
||||
|
||||
np_types = [np.float32, np.int32]
|
||||
integral_np_types = [
|
||||
np.int8,
|
||||
np.int16,
|
||||
np.int32,
|
||||
np.int64,
|
||||
np.uint8,
|
||||
np.uint16,
|
||||
np.uint32,
|
||||
np.uint64,
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_detection_output(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"keep_top_k": np.array([64], dtype=int_dtype),
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
}
|
||||
|
||||
box_logits = ov.parameter([4, 8], fp_dtype, "box_logits")
|
||||
class_preds = ov.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ov.parameter([4, 2, 10], fp_dtype, "proposals")
|
||||
aux_class_preds = ov.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ov.parameter([4, 8], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ov.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_type_name() == "DetectionOutput"
|
||||
assert node.get_output_size() == 1
|
||||
assert list(node.get_output_shape(0)) == [1, 1, 256, 7]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_dynamic_get_attribute_value(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"background_label_id": int_dtype(13),
|
||||
"top_k": int_dtype(16),
|
||||
"variance_encoded_in_target": True,
|
||||
"keep_top_k": np.array([64, 32, 16, 8], dtype=int_dtype),
|
||||
"code_type": "caffe.PriorBoxParameter.CENTER_SIZE",
|
||||
"share_location": False,
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
"confidence_threshold": fp_dtype(0.111),
|
||||
"clip_after_nms": True,
|
||||
"clip_before_nms": False,
|
||||
"decrease_label_id": True,
|
||||
"normalized": True,
|
||||
"input_height": int_dtype(86),
|
||||
"input_width": int_dtype(79),
|
||||
"objectness_score": fp_dtype(0.77),
|
||||
}
|
||||
|
||||
box_logits = ov.parameter([4, 680], fp_dtype, "box_logits")
|
||||
class_preds = ov.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ov.parameter([4, 1, 8], fp_dtype, "proposals")
|
||||
aux_class_preds = ov.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ov.parameter([4, 680], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ov.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_background_label_id() == int_dtype(13)
|
||||
assert node.get_top_k() == int_dtype(16)
|
||||
assert node.get_variance_encoded_in_target()
|
||||
assert np.all(np.equal(node.get_keep_top_k(), np.array([64, 32, 16, 8], dtype=int_dtype)))
|
||||
assert node.get_code_type() == "caffe.PriorBoxParameter.CENTER_SIZE"
|
||||
assert not node.get_share_location()
|
||||
assert np.isclose(node.get_nms_threshold(), fp_dtype(0.645))
|
||||
assert np.isclose(node.get_confidence_threshold(), fp_dtype(0.111))
|
||||
assert node.get_clip_after_nms()
|
||||
assert not node.get_clip_before_nms()
|
||||
assert node.get_decrease_label_id()
|
||||
assert node.get_normalized()
|
||||
assert node.get_input_height() == int_dtype(86)
|
||||
assert node.get_input_width() == int_dtype(79)
|
||||
assert np.isclose(node.get_objectness_score(), fp_dtype(0.77))
|
||||
@@ -2,9 +2,8 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import openvino.runtime.opset8 as ov
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -37,68 +36,6 @@ def test_dynamic_attributes_softmax():
|
||||
assert node.get_axis() == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_dynamic_get_attribute_value(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"num_classes": int_dtype(85),
|
||||
"background_label_id": int_dtype(13),
|
||||
"top_k": int_dtype(16),
|
||||
"variance_encoded_in_target": True,
|
||||
"keep_top_k": np.array([64, 32, 16, 8], dtype=int_dtype),
|
||||
"code_type": "caffe.PriorBoxParameter.CENTER_SIZE",
|
||||
"share_location": False,
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
"confidence_threshold": fp_dtype(0.111),
|
||||
"clip_after_nms": True,
|
||||
"clip_before_nms": False,
|
||||
"decrease_label_id": True,
|
||||
"normalized": True,
|
||||
"input_height": int_dtype(86),
|
||||
"input_width": int_dtype(79),
|
||||
"objectness_score": fp_dtype(0.77),
|
||||
}
|
||||
|
||||
box_logits = ov.parameter([4, 680], fp_dtype, "box_logits")
|
||||
class_preds = ov.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ov.parameter([4, 1, 8], fp_dtype, "proposals")
|
||||
aux_class_preds = ov.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ov.parameter([4, 680], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ov.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_num_classes() == int_dtype(85)
|
||||
assert node.get_background_label_id() == int_dtype(13)
|
||||
assert node.get_top_k() == int_dtype(16)
|
||||
assert node.get_variance_encoded_in_target()
|
||||
assert np.all(np.equal(node.get_keep_top_k(), np.array([64, 32, 16, 8], dtype=int_dtype)))
|
||||
assert node.get_code_type() == "caffe.PriorBoxParameter.CENTER_SIZE"
|
||||
assert not node.get_share_location()
|
||||
assert np.isclose(node.get_nms_threshold(), fp_dtype(0.645))
|
||||
assert np.isclose(node.get_confidence_threshold(), fp_dtype(0.111))
|
||||
assert node.get_clip_after_nms()
|
||||
assert not node.get_clip_before_nms()
|
||||
assert node.get_decrease_label_id()
|
||||
assert node.get_normalized()
|
||||
assert node.get_input_height() == int_dtype(86)
|
||||
assert node.get_input_width() == int_dtype(79)
|
||||
assert np.isclose(node.get_objectness_score(), fp_dtype(0.77))
|
||||
assert node.get_num_classes() == int_dtype(85)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
|
||||
@@ -110,7 +110,7 @@ def test_ctc_greedy_decoder(dtype):
|
||||
(np.float64, np.int64, "i64", "i32", False, False),
|
||||
(np.float64, np.int64, "i32", "i64", False, False),
|
||||
(np.float64, np.int64, "i64", "i64", False, False)
|
||||
],)
|
||||
], )
|
||||
def test_ctc_greedy_decoder_seq_len(fp_dtype, int_dtype, int_ci, int_sl, merge_repeated, blank_index):
|
||||
input0_shape = [8, 20, 128]
|
||||
input1_shape = [8]
|
||||
@@ -1093,41 +1093,6 @@ def test_prior_box_clustered(int_dtype, fp_dtype):
|
||||
assert list(node.get_output_shape(0)) == [2, 4332]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_detection_output(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"num_classes": int_dtype(85),
|
||||
"keep_top_k": np.array([64], dtype=int_dtype),
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
}
|
||||
|
||||
box_logits = ng.parameter([4, 8], fp_dtype, "box_logits")
|
||||
class_preds = ng.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ng.parameter([4, 2, 10], fp_dtype, "proposals")
|
||||
aux_class_preds = ng.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ng.parameter([4, 8], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ng.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_type_name() == "DetectionOutput"
|
||||
assert node.get_output_size() == 1
|
||||
assert list(node.get_output_shape(0)) == [1, 1, 256, 7]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import ngraph as ng
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
np_types = [np.float32, np.int32]
|
||||
integral_np_types = [
|
||||
np.int8,
|
||||
np.int16,
|
||||
np.int32,
|
||||
np.int64,
|
||||
np.uint8,
|
||||
np.uint16,
|
||||
np.uint32,
|
||||
np.uint64,
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_detection_output(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"keep_top_k": np.array([64], dtype=int_dtype),
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
}
|
||||
|
||||
box_logits = ng.parameter([4, 8], fp_dtype, "box_logits")
|
||||
class_preds = ng.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ng.parameter([4, 2, 10], fp_dtype, "proposals")
|
||||
aux_class_preds = ng.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ng.parameter([4, 8], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ng.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_type_name() == "DetectionOutput"
|
||||
assert node.get_output_size() == 1
|
||||
assert list(node.get_output_shape(0)) == [1, 1, 256, 7]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_dynamic_get_attribute_value(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"background_label_id": int_dtype(13),
|
||||
"top_k": int_dtype(16),
|
||||
"variance_encoded_in_target": True,
|
||||
"keep_top_k": np.array([64, 32, 16, 8], dtype=int_dtype),
|
||||
"code_type": "caffe.PriorBoxParameter.CENTER_SIZE",
|
||||
"share_location": False,
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
"confidence_threshold": fp_dtype(0.111),
|
||||
"clip_after_nms": True,
|
||||
"clip_before_nms": False,
|
||||
"decrease_label_id": True,
|
||||
"normalized": True,
|
||||
"input_height": int_dtype(86),
|
||||
"input_width": int_dtype(79),
|
||||
"objectness_score": fp_dtype(0.77),
|
||||
}
|
||||
|
||||
box_logits = ng.parameter([4, 680], fp_dtype, "box_logits")
|
||||
class_preds = ng.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ng.parameter([4, 1, 8], fp_dtype, "proposals")
|
||||
aux_class_preds = ng.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ng.parameter([4, 680], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ng.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_background_label_id() == int_dtype(13)
|
||||
assert node.get_top_k() == int_dtype(16)
|
||||
assert node.get_variance_encoded_in_target()
|
||||
assert np.all(np.equal(node.get_keep_top_k(), np.array([64, 32, 16, 8], dtype=int_dtype)))
|
||||
assert node.get_code_type() == "caffe.PriorBoxParameter.CENTER_SIZE"
|
||||
assert not node.get_share_location()
|
||||
assert np.isclose(node.get_nms_threshold(), fp_dtype(0.645))
|
||||
assert np.isclose(node.get_confidence_threshold(), fp_dtype(0.111))
|
||||
assert node.get_clip_after_nms()
|
||||
assert not node.get_clip_before_nms()
|
||||
assert node.get_decrease_label_id()
|
||||
assert node.get_normalized()
|
||||
assert node.get_input_height() == int_dtype(86)
|
||||
assert node.get_input_width() == int_dtype(79)
|
||||
assert np.isclose(node.get_objectness_score(), fp_dtype(0.77))
|
||||
@@ -1,11 +1,10 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import ngraph as ng
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import ngraph as ng
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def _proposal_node():
|
||||
@@ -37,68 +36,6 @@ def test_dynamic_attributes_softmax():
|
||||
assert node.get_axis() == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
(np.int8, np.float32),
|
||||
(np.int16, np.float32),
|
||||
(np.int32, np.float32),
|
||||
(np.int64, np.float32),
|
||||
(np.uint8, np.float32),
|
||||
(np.uint16, np.float32),
|
||||
(np.uint32, np.float32),
|
||||
(np.uint64, np.float32),
|
||||
(np.int32, np.float16),
|
||||
(np.int32, np.float64),
|
||||
],
|
||||
)
|
||||
def test_dynamic_get_attribute_value(int_dtype, fp_dtype):
|
||||
attributes = {
|
||||
"num_classes": int_dtype(85),
|
||||
"background_label_id": int_dtype(13),
|
||||
"top_k": int_dtype(16),
|
||||
"variance_encoded_in_target": True,
|
||||
"keep_top_k": np.array([64, 32, 16, 8], dtype=int_dtype),
|
||||
"code_type": "caffe.PriorBoxParameter.CENTER_SIZE",
|
||||
"share_location": False,
|
||||
"nms_threshold": fp_dtype(0.645),
|
||||
"confidence_threshold": fp_dtype(0.111),
|
||||
"clip_after_nms": True,
|
||||
"clip_before_nms": False,
|
||||
"decrease_label_id": True,
|
||||
"normalized": True,
|
||||
"input_height": int_dtype(86),
|
||||
"input_width": int_dtype(79),
|
||||
"objectness_score": fp_dtype(0.77),
|
||||
}
|
||||
|
||||
box_logits = ng.parameter([4, 680], fp_dtype, "box_logits")
|
||||
class_preds = ng.parameter([4, 170], fp_dtype, "class_preds")
|
||||
proposals = ng.parameter([4, 1, 8], fp_dtype, "proposals")
|
||||
aux_class_preds = ng.parameter([4, 4], fp_dtype, "aux_class_preds")
|
||||
aux_box_preds = ng.parameter([4, 680], fp_dtype, "aux_box_preds")
|
||||
|
||||
node = ng.detection_output(box_logits, class_preds, proposals, attributes, aux_class_preds, aux_box_preds)
|
||||
|
||||
assert node.get_num_classes() == int_dtype(85)
|
||||
assert node.get_background_label_id() == int_dtype(13)
|
||||
assert node.get_top_k() == int_dtype(16)
|
||||
assert node.get_variance_encoded_in_target()
|
||||
assert np.all(np.equal(node.get_keep_top_k(), np.array([64, 32, 16, 8], dtype=int_dtype)))
|
||||
assert node.get_code_type() == "caffe.PriorBoxParameter.CENTER_SIZE"
|
||||
assert not node.get_share_location()
|
||||
assert np.isclose(node.get_nms_threshold(), fp_dtype(0.645))
|
||||
assert np.isclose(node.get_confidence_threshold(), fp_dtype(0.111))
|
||||
assert node.get_clip_after_nms()
|
||||
assert not node.get_clip_before_nms()
|
||||
assert node.get_decrease_label_id()
|
||||
assert node.get_normalized()
|
||||
assert node.get_input_height() == int_dtype(86)
|
||||
assert node.get_input_width() == int_dtype(79)
|
||||
assert np.isclose(node.get_objectness_score(), fp_dtype(0.77))
|
||||
assert node.get_num_classes() == int_dtype(85)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"int_dtype, fp_dtype",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user