darknet无法打开data/coco.names文件处理方法

问题描述

在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.youkuaiyun.com/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

这样成功完成了人生第一个深度学习识别。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力的老周

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值