def test_proposal_props(): float_dtype = np.float32 batch_size = 1 post_nms_topn = 20 probs = ov.parameter(Shape([batch_size, 8, 255, 255]), dtype=float_dtype, name="probs") deltas = ov.parameter(Shape([batch_size, 16, 255, 255]), dtype=float_dtype, name="bbox_deltas") im_info = ov.parameter(Shape([4]), dtype=float_dtype, name="im_info") attrs = { "base_size": np.uint32(85), "pre_nms_topn": np.uint32(10), "post_nms_topn": np.uint32(post_nms_topn), "nms_thresh": np.float32(0.34), "feat_stride": np.uint32(16), "min_size": np.uint32(32), "ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=np.float32), "scale": np.array([2, 3, 3, 4], dtype=np.float32), } node = ov.proposal(probs, deltas, im_info, attrs) assert node.get_type_name() == "Proposal" assert node.get_output_size() == 2 assert list(node.get_output_shape(0)) == [batch_size * post_nms_topn, 5] assert list(node.get_output_shape(1)) == [batch_size * post_nms_topn] assert node.get_output_element_type(0) == Type.f32 assert node.get_output_element_type(1) == Type.f32
def test_dynamic_set_attribute_value(int_dtype, fp_dtype): attributes = { "base_size": int_dtype(1), "pre_nms_topn": int_dtype(20), "post_nms_topn": int_dtype(64), "nms_thresh": fp_dtype(0.34), "feat_stride": int_dtype(16), "min_size": int_dtype(32), "ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=fp_dtype), "scale": np.array([2, 3, 3, 4], dtype=fp_dtype), } batch_size = 7 class_probs = ov.parameter([batch_size, 12, 34, 62], fp_dtype, "class_probs") bbox_deltas = ov.parameter([batch_size, 24, 34, 62], fp_dtype, "bbox_deltas") image_shape = ov.parameter([3], fp_dtype, "image_shape") node = ov.proposal(class_probs, bbox_deltas, image_shape, attributes) node.set_base_size(int_dtype(15)) node.set_pre_nms_topn(int_dtype(7)) node.set_post_nms_topn(int_dtype(33)) node.set_nms_thresh(fp_dtype(1.55)) node.set_feat_stride(int_dtype(8)) node.set_min_size(int_dtype(123)) node.set_ratio(np.array([1.1, 2.5, 3.0, 4.5], dtype=fp_dtype)) node.set_scale(np.array([2.1, 3.2, 3.3, 4.4], dtype=fp_dtype)) node.set_clip_before_nms(True) node.set_clip_after_nms(True) node.set_normalize(True) node.set_box_size_scale(fp_dtype(1.34)) node.set_box_coordinate_scale(fp_dtype(0.88)) node.set_framework("OpenVINO") assert node.get_base_size() == int_dtype(15) assert node.get_pre_nms_topn() == int_dtype(7) assert node.get_post_nms_topn() == int_dtype(33) assert np.isclose(node.get_nms_thresh(), fp_dtype(1.55)) assert node.get_feat_stride() == int_dtype(8) assert node.get_min_size() == int_dtype(123) assert np.allclose(node.get_ratio(), np.array([1.1, 2.5, 3.0, 4.5], dtype=fp_dtype)) assert np.allclose(node.get_scale(), np.array([2.1, 3.2, 3.3, 4.4], dtype=fp_dtype)) assert node.get_clip_before_nms() assert node.get_clip_after_nms() assert node.get_normalize() assert np.isclose(node.get_box_size_scale(), fp_dtype(1.34)) assert np.isclose(node.get_box_coordinate_scale(), fp_dtype(0.88)) assert node.get_framework() == "OpenVINO"
def _proposal_node(): attributes = { "base_size": np.uint16(1), "pre_nms_topn": np.uint16(20), "post_nms_topn": np.uint16(64), "nms_thresh": np.float64(0.34), "feat_stride": np.uint16(16), "min_size": np.uint16(32), "ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=np.float64), "scale": np.array([2, 3, 3, 4], dtype=np.float64), } batch_size = 7 class_probs = ov.parameter([batch_size, 12, 34, 62], np.float64, "class_probs") bbox_deltas = ov.parameter([batch_size, 24, 34, 62], np.float64, "bbox_deltas") image_shape = ov.parameter([3], np.float64, "image_shape") return ov.proposal(class_probs, bbox_deltas, image_shape, attributes)