问题描述
在win10下通过git获取了darknet的源码,然后打包拷贝到Ubuntu18.04。按照darknet网站介绍成功编译了darknet。下面开始darknet训练。
$ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg Couldn't open file: data/coco.names
好吧,发现data/coco.names其实是存在的。
求助万能的baidu,果然发现有解决方法。参考https://blog.csdn.net/qq_39852676/article/details/91976390。
发生以上的原因,可能是模型直接从window系统上的复制到linux系统上,因为两者系统对文本的编码方式不同,导致运行出错。或者是运行的coco.names文件是从windows系统是直接复制的,导致此问题。
使用vim打开coco.names。
$ vim data/coco.names
输入 :set ff?
果然得到 fileformat=dos
按照上面所说将对应的darknet目录下所有的文件都改成unix模式。修改的方法如下
$ sudo apt-get install dos2unix $ sudo find ./ -name "*.cfg" | xargs dos2unix $ sudo find ./ -name "*.names" | xargs dos2unix
修改完成后,再次运行。
$ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg Couldn't open file: data/coco.names
好吧,发现还是同样问题,百思不得其解。
解决方法
好吧。不知道为什么解决不了。只好删除原有的darknet,利用git命令重新获得。
$ rm -rf darknet $ git clone https://github.com/pjreddie/darknet
然后再次编译,解决这个问题。
$ cd darknet/ $ make $ cp /mnt/hgfs/share/yolov3.weights . $ ./darknet detect cfg/yolov3.cfg yolov3.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 0.639 BFLOPs 1 conv 64 3 x 3 / 2 608 x 608 x 32 -> 304 x 304 x 64 3.407 BFLOPs 2 conv 32 1 x 1 / 1 304 x 304 x 64 -> 304 x 304 x 32 0.379 BFLOPs 3 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64 3.407 BFLOPs 4 res 1 304 x 304 x 64 -> 304 x 304 x 64 5 conv 128 3 x 3 / 2 304 x 304 x 64 -> 152 x 152 x 128 3.407 BFLOPs 103 conv 128 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BFLOPs 104 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BFLOPs 105 conv 255 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 255 0.754 BFLOPs 106 yolo Loading weights from yolov3.weights...Done! data/dog.jpg: Predicted in 42.598981 seconds. dog: 100% truck: 92% bicycle: 99% $ ls predictions.jpg predictions.jpg
这样成功完成了人生第一个深度学习识别。