可以直接获取当前的虚拟机,无需将时间用在搭建开发环境上,让更多的精力实现更有价值的学习。
模型转换的虚拟机:链接:https://pan.baidu.com/s/1xiB3n7WxYIz8BqzojfsXyw提取码:42lq
YOLOv3的darknet模型转caffe模型
包括:YOLOv3、YOLOv3-spp、YOLOv3-tiny的模型
输入模型
#输入模型路径
/home/wyj/HaiSi/darknet2caffe/weights
/home/wyj/HaiSi/darknet2caffe/cfg

输出模型
#输出模型路径
/home/wyj/HaiSi/darknet2caffecaffemodel
/home/wyj/HaiSi/darknet2caffe/prototxt

模型转换
#YOLOv3的darknet模型转caffe模型
cd /home/wyj/HaiSi/darknet2caffe
python3 darknet2caffe.py cfg/yolov3.cfg weights/yolov3.weights prototxt/yolov3.prototxt caffemodel/yolov3.caffemodel
python3 darknet2caffe.py cfg/yolov3-spp.cfg weights/yolov3-spp.weights prototxt/yolov3-spp.prototxt caffemodel/yolov3-spp.caffemodel
python3 darknet2caffe.py cfg/yolov3-tiny.cfg weights/yolov3-tiny.weights prototxt/yolov3-tiny.prototxt caffemodel/yolov3-tiny.caffemodel



caffe模型测试
cd /home/wyj/HaiSi/YOLOv3-caffe-master
python3 detect_one.py
测试结果

测试前需要修改配置文件
打开文件:/home/wyj/wyj/YOLOv3-caffe-master/detect_one.py
修改模型路径、测试标签文件路径、测试图片路径、测试模型的尺寸

针对不同的测试模型输出的模型结构节点名称不同需要修改源码
输入模型结构的第一层输入节点名称:/home/wyj/wyj/YOLOv3-caffe-master/detect_one.py


输出的最后节点名称:/home/wyj/wyj/YOLOv3-caffe-master/utils.py


YOLOx的onnx模型转caffe模型
yolox:https://github.com/Megvii-BaseDetection/YOLOX
官方原始测试
cd /home/wyj/HaiSi/YOLOX
python3 tools/demo.py image -f exps/example/yolox_voc/yolox_voc_s.py -c best_ckpt.pth.tar --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu

测试结果输出路径
./YOLOX_outputs/yolox_voc_s/vis_res/2024_03_11_23_44_04/dog.jpg

输入模型路径
/home/wyj/HaiSi/onnx2caffe-master

输出模型路径
/home/wyj/HaiSi/onnx2caffe-master

yolox的模型转换
cd /home/wyj/HaiSi/onnx2caffe-master
python3 convertCaffe.py yolox_True.onnx yolox_true.prototxt yolox_true.caffemodel

安装caffe中遇到的问题和解决办法
解决办法是依据出现错误的顺序而给出的,为了方便,可以直接先执行所有解决办法后再安装caffe。
1. ./include/caffe/common.hpp:5:27: fatal error: gflags/gflags.h: No such file or directory
解决办法:sudo apt-get install libgflags-dev
2. ./include/caffe/util/mkl_alternate.hpp:14:19: fatal error: cblas.h: No such file or directory
解决办法:sudo apt-get install libblas-dev
3. ./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
解决办法:在Makefile.config找到以下行并添加蓝色部分
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
4. ./include/caffe/util/db_lmdb.hpp:8:18: fatal error: lmdb.h: No such file or directory
解决办法:sudo apt install liblmdb-dev
5. /usr/bin/ld: cannot find -lcblas /usr/bin/ld: cannot find -latlas
解决办法:sudo apt install libatlas-base-dev