下载darknet
mkdir -p ~/dl/darknet
cd ~/dl/darknet
git clone https://github.com/pjreddie/darknet.git
cd darknet
修改makefile
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命令编译,j6表示6核处理,j4表示4核处理
make -j6
测试
下载训练好的YOLOv3模型
wget https://pjreddie.com/media/files/yolov3.weights
测试运行
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
下载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"