海思3159A运行yolov3(三)——darknet2caffe

可以参考原作者:https://github.com/ChenYingpeng/darknet2caffe

 

一、环境

Python2.7

Caffe

Pytorch >= 0.40

二、caffe参数配置

1. caffe_layers/mish_layer/mish_layer.hpp,caffe_layers/upsample_layer/upsample_layer.hpp into include/caffe/layers/.
2. Copy caffe_layers/mish_layer/mish_layer.cpp mish_layer.cu,caffe_layers/upsample_layer/upsample_layer.cpp upsample_layer.cu into src/caffe/layers/.
3. Copy caffe_layers/pooling_layer/pooling_layer.cpp into src/caffe/layers/.Note:only work for yolov3-tiny,use with caution.
4. Add below code into src/caffe/proto/caffe.proto.

// LayerParameter next available layer-specific ID: 147 (last added: recurrent_param)
message LayerParameter {
  optional TileParameter tile_param = 138;
  optional VideoDataParameter video_data_param = 207;
  optional WindowDataParameter window_data_param = 129;
++optional UpsampleParameter upsample_param = 149; //added by chen for Yolov3, make sure this id 149 not the same as before.
++optional MishParameter mish_param = 150; //added by chen for yolov4,make sure this id 150 not the same as before.
}

// added by chen for YoloV3
++message UpsampleParameter{
++  optional int32 scale = 1 [default = 1];
++}

// Message that stores parameters used by MishLayer
++message MishParameter {
++  enum Engine {
++    DEFAULT = 0;
++    CAFFE = 1;
++    CUDNN = 2;
++  }
++  optional Engine engine = 2 [default = DEFAULT];
++}

然后重新编译caffe

make clean

make all -j8

make pycaffe

三、模型转换

python darknet2caffe.py cfg/yolov3.cfg weights/yolov3.weights prototxt/yolov3.prototxt caffemodel/yolov3.caffemodel

四、模型验证

eval...

你可能感兴趣的:(海思AI,caffe,caffe,yolov3)