玩转Jetson Nano(五)跑通yolov3

yoloV3也是一个物品检测的小程序,而且搭建起来比较简单。这里要申明,本文用的是yoloV3的tiny版,正式版和tiny版安装的方法都是一样的,只是运行时的配置文件和权重文件不一样。我曾经试图跑正式版,但是跑不起来,基本上到第二次卷积就挂掉了,毕竟nano只有4G内存。

闲话少说,开始安装。

1. 安装CUDA,OpenCV,cuDNN

不说了,如果没安装的请看前文吧。

2. 下载

git clone https://github.com/pjreddie/darknet.git

3. 配置

cd darknet
sudo vim Makefile   #修改Makefile

4.  将Makefile的前三行修改一下

GPU=1
CUDNN=1
OPENCV=1

5.  编译

make -j4

6. 下载权重文件,这里直接下载tiny版的权重文件

wget https://pjreddie.com/media/files/yolov3-tiny.weights

 7.  测试

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg
layer     filters    size              input                output
    0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  16  0.150 BFLOPs
    1 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  16
    2 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  32  0.399 BFLOPs
    3 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  32
    4 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  64  0.399 BFLOPs
    5 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  64
    6 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 128  0.399 BFLOPs
    7 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 128
    8 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 256  0.399 BFLOPs
    9 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 256
   10 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   11 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 512
   12 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   13 conv    256  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 256  0.089 BFLOPs
   14 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   15 conv    255  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 255  0.044 BFLOPs
   16 yolo
   17 route  13
   18 conv    128  1 x 1 / 1    13 x  13 x 256   ->    13 x  13 x 128  0.011 BFLOPs
   19 upsample            2x    13 x  13 x 128   ->    26 x  26 x 128
   20 route  19 8
   21 conv    256  3 x 3 / 1    26 x  26 x 384   ->    26 x  26 x 256  1.196 BFLOPs
   22 conv    255  1 x 1 / 1    26 x  26 x 256   ->    26 x  26 x 255  0.088 BFLOPs
   23 yolo
Loading weights from yolov3-tiny.weights...Done!
data/dog.jpg: Predicted in 0.239507 seconds.
dog: 56%
car: 52%
truck: 56%
car: 62%
bicycle: 58%

8. 资源不够时应对方案

Nano的内存还是太小了,有时候需要swap扩一下内存.nano重启后,swap空间自动回收。

# 先禁用以前的
sudo swapoff /swapfile

# 修改swap 空间的大小为4G
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

# 设置文件为“swap file”类型
sudo mkswap /swapfile

# 启用swapfile
sudo swapon /swapfile

 

评论 52
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值