Darknet encapsulates object detection and image classification models, which gives us a user-friendly interface to deploy advanced deep learning models.
Here I use Darknet to perform coral reef detection in inner hackathon.
The page gives detailed information about how to install Darknet, training YOLO on VOC or COCO datasets.
The following steps following Training YOLO on VOC part.
- Build Darknet in GPU mode
- If you don't know the cuda path, try
whereis nvcc
- OpenCV error
- If you don't know the cuda path, try
- Prepare the training data YOLO needs
- Refer to
https://pjreddie.com/media/files/voc_label.py
. For each image, there is a txt file contains several lines that format like this<object-class> <x> <y> <width> <height>
. Each line represents a object in the image.
- Refer to
- Create three config files
- Model configuration file:
darknet/cfg/your_file_name.cfg
- Copy
darknet/cfg/yolov3.cfg
todarknet/cfg/your_file_name.cfg
, reviseLine 7, 8..
refer from here
- Copy
- Data configuration file:
darknet/cfg/your_file_name.data
- Copy
darknet/cfg/voc.data
todarknet/cfg/your_file_name.data
, revise all lines. - The backup folder stores trained models.
- The names stores the labels of training data specified in the following Data label file.
- Copy
- Data label file:
darknet/data/your_file_name.names
- Copy
darknet/data/voc.names
todarknet/data/your_file_name.names
, each row corresponding to one label.
- Copy
- Model configuration file:
- Train the model
- Execute
./darknet detector train cfg/your_file_name.data cfg/your_file_name.cfg darknet53.conv.74
, wheredarknet53.conv.74
is pretrained model weights.
- Execute
- Evulate the model
- Compute the
recall
:./darknet detector recall data/your_file_name.names cfg/your_file_name.cfg your_model_x00.weights
. - If ERROR
data/coco_val_5k.list is not found
happens, here is the solution.
- Compute the
- Use the model
- Execute
./darknet detector test cfg/your_file_name.data cfg/your_file_name.cfg your_model_x00.weights your_test_image_path
. - The result of above command is
predictions.png
.
- Execute