1.直接设置使用,编译通过
git clone https://github.com/pjreddie/darknet.git cd darknet make
2. 下载权重测试
wget http://pjreddie.com/media/files/yolo.weights ./darknet yolo test cfg/yolo.cfg yolo.weights data/dog.jpg
3.测试结果:
dsp@dsp:/media/dsp/学习/yolo_darknet/darknet$ ./darknet yolo test cfg/yolo.cfg yolo.weights data/dog.jpg layer filters size input output 0 conv 32 3 x 3 / 1 608 x 608 x 3 -> 608 x 608 x 32 1 max 2 x 2 / 2 608 x 608 x 32 -> 304 x 304 x 32 2 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64 3 max 2 x 2 / 2 304 x 304 x 64 -> 152 x 152 x 64 4 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 5 conv 64 1 x 1 / 1 152 x 152 x 128 -> 152 x 152 x 64 6 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 7 max 2 x 2 / 2 152 x 152 x 128 -> 76 x 76 x 128 8 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 9 conv 128 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 128 10 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 11 max 2 x 2 / 2 76 x 76 x 256 -> 38 x 38 x 256 12 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 13 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 14 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 15 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 16 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 17 max 2 x 2 / 2 38 x 38 x 512 -> 19 x 19 x 512 18 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 19 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 20 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 21 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 22 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 23 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 24 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 25 route 16 26 conv 64 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 64 27 reorg / 2 38 x 38 x 64 -> 19 x 19 x 256 28 route 27 24 29 conv 1024 3 x 3 / 1 19 x 19 x1280 -> 19 x 19 x1024 30 conv 425 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 425 31 detection mask_scale: Using default '1.000000' Loading weights from yolo.weights...Done! data/dog.jpg: Predicted in 9.566333 seconds. Not compiled with OpenCV, saving to predictions.png instead
- 区分上下连个命令:
./darknet yolo test cfg/yolo.cfg yolo.weights data/dog.jpg
./darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg
-/darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg 结果:
4.设置GPU和opencv
GPU=1 OPENCV=1
-编译错误
/usr/bin/ld: cannot find -lippicv collect2: error: ld returned 1 exit status Makefile:76: recipe for target 'darknet' failed make: *** [darknet] Error 1 /usr/bin/ld: cannot find -make: *** Waiting for unfinished jobs.... lippicv collect2: error: ld returned 1 exit status Makefile:82: recipe for target 'libdarknet.so' failed make: *** [libdarknet.so] Error 1
- opencv安装的问题,于是重新安装
https://github.com/pjreddie/darknet/issues/290: /usr/bin/ld: cannot find -lippicv collect2: error: ld returned 1 exit status
https://github.com/opencv/opencv/issues/5852这篇文章中也遇到了这个错误. 可以在cmake时加上"cmake -DINSTALL_CREATE_DISTRIB=ON"
这句,就不会有这个错误了.
- 首先卸载opencv,然后在安装 :卸载参考:Ubuntu16.04 上openCV的卸载与 opencv3.0.2安装记录
cd /home/hy/opencv/build make uninstall//卸载掉配置路径中的文件 sudo rm -r build//删除build文件 //删除掉环境中有关的其余包 sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
-安装,安装有图割错误,以前解决办法
dsp@dsp:~/opencv-3.1.0/build$ sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. -DWITH_IPP=ON -DINSTALL_CREATE_DISTRIB=ON dsp@dsp:~/opencv-3.1.0/build$ sudo make -j$(nproc)
5. 在编译darknet
dart -lcublas -lcurand -lcudnn -lstdc++ libdarknet.a /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFReadRGBAStrip@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFWriteEncodedStrip@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFIsTiled@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFGetField@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFNumberOfStrips@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFReadEncodedTile@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFReadRGBATile@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFClose@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFRGBAImageOK@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFOpen@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFReadEncodedStrip@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFSetField@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0' collect2: error: ld returned 1 exit status Makefile:76: recipe for target 'darknet' failed make: *** [darknet] Error 1 //权限问题,sudo即可解决 这个可能是权限问题,采用以下指令: sudo su; 一切都能顺利解决。
6. 运行yolo和yolo9000,可以实现demo运行,并实现视频检测
YOLOv2是Joseph Redmon提出的针对YOLO算法不足的改进版本,作者使用了一系列的方法对原来的YOLO多目标检测框架进行了改进,在保持原有速度的优势之下,精度上得以提升,此外作者提出了一种目标分类与检测的联合训练方法,通过这种方法YOLO9000可以同时在COCO和ImageNet数据集中进行训练,训练后的模型可以实现多达9000种物体的实时检测。
-
第一种:为darknet添加Python接口
-
第二种:使用keras