The files referenced below can be found in this repository.
-
Fork this repo into your Github account and clone it to your local machine.
-
Ensure that the requirements for this project are met. Visit the Setup page for information on setting up your environment.
-
Replace the Makefile with the one in the repository specified above or configure the file accordingly:
-
GPU=1 # (Line 1)
-
OPENCV=1 # (Line 4)
-
NVCC=/usr/local/cuda/bin/nvcc # Or the path to your NVCC - (Line 57)
-
LDFLAGS+= `pkg-config --libs opencv4` # (Line 79) COMMON+= `pkg-config --cflags opencv4` # (Line 80)
-
-
Run
make
in the root of the project. -
If darknet has compiled successfully, running
./darknet
in the root of the project should return:usage: ./darknet <function>
-
Label the images in the potholes dataset. The dataset provided in this link already has the images labelled. Each image should be accompanied by a text file that describes the bounding boxes of the pothole(s) in the image. You can learn more about the format of these labelling files here.
The directory holding your formatted data should look like this after creating the text files:
-
Place the files
obj.data
,obj.names
,yolo-pothole-test.cfg
, andyolo-pothole-train.cfg
in thecfg/
directory of the project. -
Import the formatted data with both the JPEG and text files into the
data/Pothole/
directory. This directory will have to be created. -
Place the
train.txt
andtest.txt
files in thedata/Pothole/
directory as well. -
Training requires a set of convolutional weights that can be downloaded from the official YOLO website here. Place these weights in the root of the project.
-
Start the training by running:
./darknet detector train cfg/obj.data cfg/yolo-pothole-train.cfg darknet19_448.conv.23
Note: The weights save every 100 iterations until the 1000th iteration, after which it saves every 1000 iterations. The program will also save the weights every 100 iterations as a
<training_config>_last.weights
fileThe output from the training should look something like this:
-
To resume training using an existing weight, run:
./darknet detector train cfg/obj.data cfg/yolo-pothole-train.cfg <last_weight_file>
-
You should stop training when the mean average precision (mAP) is the highest. To get the mAP of a weight:
./darknet detector map cfg/obj.data cfg/yolo-pothole-train.cfg <weight_file>
Read here for more info.
-
Once the training is complete, you can test the detection by running:
-
For image files:
./darknet detector test cfg/obj.data cfg/yolo-pothole-test.cfg <trained_weight_file> <image_file>
Note: The image will automatically be saved as
predictions.jpg
-
For video files:
./darknet detector demo cfg/obj.data cfg/yolo-pothole-test.cfg <trained_weight_file> <video_file> -out_filename <video_output>.avi
Here's a reference to the command
-
Check out the Troubleshooting section if you run into any problems.