昇腾社区首页
中文
注册

PointPillars后处理网络模型prototxt修改

本章节说明pointpillars网络后处理使用方式,算子的详细规格信息,请参考支持Caffe&TensorFlow&ONNX算子清单>支持Caffe算子清单中的PointPillarDecodeBox~PointPillarDetection算子,三个算子分别进行网络输出的框、分类置信度归一化、最终检测结果的计算。

注意:caffe.proto的LayerParameter中已经添加了对应的参数层信息,用户只需要根据模型的具体参数规格修改网络模型prototxt中的参数。

  1. 在LayerParameter中添加如下参数层:
    message LayerParameter {
    ...
      optional PointpillarDecodeBoxParameter decode_box_param=251;
      optional PointpillarClassCalParameter cls_cal_param=1518;
      optional PointpillarPillarDetectionParameter pillar_detection_param=253;
    ...
    }
  2. 在caffe.proto中增加如下参数:
    message PointpillarClassCalParameter {
       optional bool use_sigmoid = 1 [default = true];
    }
    
    message PointpillarPillarDetectionParameter {
       required float thresh = 1;
       optional int32 per_class_num = 2;
    }
    
    message PointpillarDecodeBoxParameter {
       repeated float box1_size = 1;
       repeated float box2_size = 2;
       repeated float box3_size = 3;
       repeated float box4_size = 4;
       repeated float rotations = 5;
       optional float x_start = 6 [default = 1];
       optional float y_start = 7 [default = 1];
       optional float x_strides = 8 [default = 1];
       optional float y_strides = 9 [default = 1];
       repeated float z_strides = 10;
    }
  3. 后处理对应prototxt文件如下:
    input: "coor"
    input: "class"
    input: "head"
    input_shape {
      dim: 1
      dim: 56 
      dim: 288
      dim: 288
    }
    input_shape {
      dim: 1
      dim: 32 
      dim: 288
      dim: 288
    }
    input_shape {
      dim: 1
      dim: 16
      dim: 288
      dim: 288
    }
    
    
    layer {
      type: 'PointPillarDecodeBox'
      name: 'decode_box'
      bottom: 'coor'
      top: 'decode_coor'
      decode_box_param {
        box1_size: 0.68
        box1_size: 0.67
        box1_size: 1.77
        box2_size: 1.92
        box2_size: 4.74
        box2_size: 1.72
        box3_size: 0.81
        box3_size: 1.99
        box3_size: 1.68
        box4_size: 1.31
        box4_size: 1.21
        box4_size: 1.00
        rotations: 0
        rotations: 1.5708
    
        x_start: -22.96
        y_start: -22.96
        x_strides: 0.16
        y_strides: 0.16
        z_strides: -0.18
        z_strides: -0.17
        z_strides: -0.28
        z_strides: -0.21
      }
    }
    
    layer {
      type: 'ClassCal'
      name: 'cls_cal'
      bottom: 'class'
      bottom: 'head'
      top: 'class_prob'
      top: 'head_direct'
      cls_cal_param {
        use_sigmoid: True 
      }
    }
    
    layer {
      type: 'PointPillarDetection'
      name: 'pillar_detection'
      bottom: 'decode_coor'
      bottom: 'class_prob'
      bottom: 'head_direct'
      top: 'box'
      pillar_detection_param {
        thresh: 0.5
      }
    }