TX2入门教程软件篇-安装Yolo v3(jetpack4.2.3)
TX2入门教程软件篇-安装Yolo v3(jetpack4.2.3)
说明:
- 介绍在tx2下安装安装Yolo v3
- 环境:jetpack4.2.3 + CUDA10 + opencv 3.3.1
步骤:
- 先增加swap分区,要不后面运行测试容易出现内存不足导致失败,参考增加swap教程
- 下载darknet
mkdir -p ~/dl/darknet
cd ~/dl/darknet
git clone https://github.com/pjreddie/darknet.git
cd darknet
- 修改Makefile文件,启用GPU和opencv
- CUDA 架构 TX2 是“62”, TX1 “53”
GPU=1
CUDNN=1
OPENCV=1
OPENMP=0
DEBUG=0
ARCH= -gencode arch=compute_53,code=[sm_53,compute_53] \
-gencode arch=compute_62,code=[sm_62,compute_62]
# -gencode arch=compute_20,code=[sm_20,sm_21] \ This one is deprecated?
# This is what I use, uncomment if you know your arch and want to specify
# ARCH= -gencode arch=compute_52,code=compute_52
- 编译
make -j4
- 判断成功
./darknet
usage: ./darknet <function>
测试yolov3
- 下载训练好的yolov3模型
wget https://pjreddie.com/media/files/yolov3.weights
- 测试运行
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
- 下载训练好的tiny yolov3模型
wget https://pjreddie.com/media/files/yolov3-tiny.weights
- 测试运行
./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg
- 使用摄像头进行实时检测
- 默认tx2的内置摄像头占用了video0,使用-c指定video1
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights -c 1
- 或使用视频文件
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights <video file>
- 或使用板载摄像头
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height(int)720, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"
参考:
- https://pjreddie.com/darknet/yolo/
- https://pjreddie.com/darknet/install/
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号