This article has participated in the activity of “New person creation Ceremony”, and started the road of digging gold creation together

Compile Darknet

Git clone github.com/pjreddie/da…

Modify the Makefile file

GPU=1 CUDNN=1 OPENCV=1 OPENMP=0 DEBUG=0

cd darknet
make
Copy the code

CUDA installation:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pinsudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pubsudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda
Copy the code

Reference links:Developer.nvidia.com/zh-cn/cuda-…

Download CUDNN and install it;

Reference links: developer.nvidia.com/rdp/cudnn-a…

After the installation, restart

sudo reboot
Copy the code

Because the pJreddie version of DarkNet is older and relies on CUDnn7.x, compiling the Pjreddie version of Darknet in a CUDA11.1+ CUDNn8.x environment will cause errors.

Solution: Modify the SRC/SRC /convolutional_layer.c file to add:

#define PRINT_CUDNN_ALGO 0
#define MEMORY_LIMIT 2000000000
Copy the code

Reference links:Blog.csdn.net/qq_41580422…

Because OpenCV version is too high (OpenCV 4.4), modify SRC /image_opencv. CPP to change line 63 to:

  //IplImage ipl = m;
    IplImage ipl = cvIplImage(m);
Copy the code

Reference link: blog.csdn.net/baidu_34172…

Modify the Makefile

The path is modified according to its own content

Reference link: blog.csdn.net/Chen_qi_hai…

Cuda version is too high and does not support computing.Reference links:Blog.csdn.net/weixin_4119…

Compile successfully, simple test:

Download weight:

cd darknet
Copy the code
wget https://pjreddie.com/media/files/yolov3.weights
Copy the code
wget https://pjreddie.com/media/files/yolov3-tiny.weights
Copy the code
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
Copy the code

The cause of this problem is video memory exploding.

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg 
Copy the code

Model training using Darknet deep learning framework

Download the annotated dataset;

  • Convert dataset VOC (.xml) from YOLO(.txt)

  • Partition data set (galss_train.txt) and training set (glass_val.txt)

Modify data/voc.names file:

Modify the CFG/voc. DataTo modify its own path

Modify the CFG/yolov3 – tiny. CFG

I need to change two of these things, I need to change classes,filter=3(classes+1+4);*

Download pre-training weights:

wget https://pjreddie.com/media/files/yolov3_tiny.weights
./darknet partial ./cfg/yolov3-tiny.cfg ./yolov3-tiny.weights ./yolov3-tiny.conv.15 15
Copy the code

Training model:

sudo ./darknet detector train cfg/voc.data cfg/yolov3-tiny.cfg yolov3-tiny.conv.15
sudo ./darknet detector train cfg/voc.data cfg/yolov3-tiny.cfg backup/yolov3-tiny_10000.weights -map
Copy the code

Models are automatically saved;

Model testing:

 ./darknet detector test cfg/voc.data cfg/yolov3-tiny.cfg backup/yolov3-tiny_10000.weights data/11.png
Copy the code

Test results: