Deep learning compiles darknet to train its own dataset

deep learning

foreword

If we want YOLO to recognize the targets we specified, we need to prepare a set of data sets first, and then train YOLO to "teach" YOLO to recognize these targets. The result of the training is to generate a .weight weight file. When it is recognized, load this weight file to recognize the target we specified.

1. Environment Construction

Due to the limited computing power of jetson nano, it is not suitable for training. So we need to build another training environment and compile darknet.
The training environment is divided into two types in terms of hardware:
①Desktop or notebook, x64 platform equipment, must have NVIDIA graphics card. In this case, you need to install the Ubuntu system by yourself, and then install the NVIDIA graphics card driver, CUDA, and cuDNN (see the previous two articles).
After configuring the above environment, download darknet and compile it.
②NVIDIA's embedded devices, including Jetson AGX Xavier, Jetson Xavier NX, etc., CUDA has been configured in the official image provided by NVIDIA, and we do not need to configure the environment by ourselves.
After CUDA is configured, run nvcc -V to check
insert image description here
the version information: NVIDIA embedded devices need to configure environment variables to run the nvcc command:
Open the ~/.bashrc file and edit:

nano ~/.bashrc

Add the following statement at the end of the file:

export LD_LIBRARY_PATH=/usr/local/cuda/lib 
export PATH=$PATH:/usr/local/cuda/bin

After pressing crtl+x to save and exit, the source takes effect:

source ~/.bashrc

After completing the above steps, the NVIDIA embedded device can run the nvcc command normally, otherwise the subsequent compilation will report an error.

2. Compile darknet

Download the code: git clone https://github.com/AlexeyAB/darknet
After decompressing the compressed package, cd to the darknet directory in the terminal, and enter make to compile it.
Note: Before make, find the makefile, we can set some functions according to our own needs, among which GPU and CUDNN are necessary.

makefile compilation parameters:
insert image description here
After installation, you can use the official .weight file for testing.

wget https://pjreddie.com/media/files/yolov3-tiny.weights //下载权重文件
./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg

The probability that you will see some objects, I won't attach screenshots here.
In addition, if you need to display pictures or test video streams in real time during testing, you need to install OpenCV, and change the OPENCV option to OPENCV=1 in the above makefile.

Summarize

Finally, the environment is all set, and the next step is how to label the data set.

Guess you like

Origin blog.csdn.net/qq_51963216/article/details/124215494