示例#1
0
    def extract(cls, node):
        proto_layer = node.pb
        param = proto_layer.prior_box_param

        variance = param.variance
        if len(variance) == 0:
            variance = [0.1]

        update_attrs = {
            'width': list(param.width),
            'height': list(param.height),
            'flip': int(param.flip),
            'clip': int(param.clip),
            'variance': list(variance),
            'img_size': param.img_size,
            'img_h': param.img_h,
            'img_w': param.img_w,
            'step': param.step,
            'step_h': param.step_h,
            'step_w': param.step_w,
            'offset': param.offset,
        }

        mapping_rule = merge_attrs(param, update_attrs)

        mapping_rule.update(layout_attrs())

        # update the attributes of the node
        PriorBoxClusteredOp.update_node_stat(node, mapping_rule)
        return cls.enabled
示例#2
0
    def extract(cls, node):
        variance = onnx_attr(node,
                             'variance',
                             'floats',
                             default=[],
                             dst_type=lambda x: np.array(x, dtype=np.float32))
        if len(variance) == 0:
            variance = [0.1]

        update_attrs = {
            'width':
            onnx_attr(node,
                      'width',
                      'floats',
                      dst_type=lambda x: np.array(x, dtype=np.float32)),
            'height':
            onnx_attr(node,
                      'height',
                      'floats',
                      dst_type=lambda x: np.array(x, dtype=np.float32)),
            'flip':
            onnx_attr(node, 'flip', 'i', default=0),
            'clip':
            onnx_attr(node, 'clip', 'i', default=0),
            'variance':
            list(variance),
            'img_size':
            onnx_attr(node, 'img_size', 'i', default=0),
            'img_h':
            onnx_attr(node, 'img_h', 'i', default=0),
            'img_w':
            onnx_attr(node, 'img_w', 'i', default=0),
            'step':
            onnx_attr(node, 'step', 'f', default=0.0),
            'step_h':
            onnx_attr(node, 'step_h', 'f', default=0.0),
            'step_w':
            onnx_attr(node, 'step_w', 'f', default=0.0),
            'offset':
            onnx_attr(node, 'offset', 'f', default=0.0),
        }

        # update the attributes of the node
        PriorBoxClusteredOp.update_node_stat(node, update_attrs)
        return cls.enabled