darknet yolov3 yolov4转caffe 教程
2021/10/30 23:44:09
本文主要是介绍darknet yolov3 yolov4转caffe 教程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
在目标检测任务中,我们常使用yolov3, yolov4作为目标检测模型,在实际部署工作中,我们很多边缘设备需要把模型转换成caffe。在次记录下转换过程。
我们需要在caffe框架中,添加所需要的层。这个转换工具可以参考github上一位大佬项目:
git clone https://github.com/ChenYingpeng/darknet2caffe.git
把大佬mish_layer文件中的mish_layer.hpp和upsample_layer文件中的upsample_layer.hpp复制到安装caffe目录下的include/caffe/layers/文件夹中。
├── mish_layer │ ├── mish_layer.cpp │ ├── mish_layer.cu │ └── mish_layer.hpp ├── pooling_layer │ └── pooling_layer.cpp └── upsample_layer ├── upsample_layer.cpp ├── upsample_layer.cu └── upsample_layer.hpp
把大佬mish_layer文件中的mish_layer.cpp、mish_layer.cu 和 upsample_layer文件中的
upsample_layer.cpp、upsample_layer.cu复制到caffe目录下的/src/caffe/layers/文件夹中。
最后在caffe目录下的/src/caffe/proto/caffe.proto。打开这个文件,添加以下内容:
在423行下面添加:
optional UpsampleParameter upsample_param = 149; optional MishParameter mish_param = 150;
在最后一行下添加如下内容:
message UpsampleParameter{ optional int32 scale = 1 [default = 1]; } message MishParameter { enum Engine { DEFAULT = 0; CAFFE = 1; CUDNN = 2; } optional Engine engine = 2 [default = DEFAULT]; }
然后我们重新编译一下caffe,在caffe/build目录下
sudo make clean sudo make all -j8 sudo make pycaffe -j8
最后执行转换命令
python3 darknet2caffe.py
打印信息如下
I1030 22:34:06.650609 7437 net.cpp:202] layer1-conv does not need backward computation. I1030 22:34:06.650612 7437 net.cpp:202] input does not need backward computation. I1030 22:34:06.650614 7437 net.cpp:244] This network produces output layer139-conv I1030 22:34:06.650619 7437 net.cpp:244] This network produces output layer150-conv I1030 22:34:06.650621 7437 net.cpp:244] This network produces output layer161-conv I1030 22:34:06.650758 7437 net.cpp:257] Network initialization done. unknow layer type yolo unknow layer type yolo save prototxt to ./yolov4.protofile save caffemodel to ./yolov4.caffemode
这篇关于darknet yolov3 yolov4转caffe 教程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-03微信支付提示下单账户与支付账户不一致-icode9专业技术文章分享
- 2024-07-03微信支付提示订单号重复-icode9专业技术文章分享
- 2024-07-02微服务启动nacos注册上去了,但是一直没有收到请求-icode9专业技术文章分享
- 2024-07-02如何检查文件的编码格式-icode9专业技术文章分享
- 2024-07-02sublime 更改编码格式-icode9专业技术文章分享
- 2024-06-30uniAPP 实现全屏左右滚动滚动的效果-icode9专业技术文章分享
- 2024-06-30如何在本地使用授权或插件-icode9专业技术文章分享
- 2024-06-30伪静态规则配置方法汇总-icode9专业技术文章分享
- 2024-06-29易优CMS安装常见问题汇总-icode9专业技术文章分享
- 2024-06-28易优新手必读安装教程-icode9专业技术文章分享