NX入门教程软件篇-安装Yolo v2v3v4和tiny(jetpack4.4)
NX入门教程软件篇-安装Yolo v2v3v4和tiny(jetpack4.4)
说明:
- 介绍在NX下安装安装Yolo v2v3v4和tiny
- 环境:jetpack4.4 + CUDA10.2 + opencv 4.1.1
步骤:
- 先增加swap分区,要不后面运行测试容易出现内存不足导致失败,参考增加swap教程
- 下载darknet
mkdir -p ~/dl
cd ~/dl/
git clone https://github.com/pjreddie/darknet.git
cd darknet
- 修改Makefile文件,启用GPU和opencv
GPU=1
CUDNN=1
CUDNN_HALF=1
OPENCV=1
AVX=0
OPENMP=0
LIBSO=1
ZED_CAMERA=0 # ZED SDK 3.0 and above
ZED_CAMERA_v2_8=0 # ZED SDK 2.X
ARCH= -gencode arch=compute_53,code=[sm_53,compute_53] \
-gencode arch=compute_72,code=[sm_72,compute_72]
# -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/
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号