This work uses darknet and YOLO for the object detection. YOLO is implemented using AlexayAB's darknet repository: link
- Cuda 10
- cuDNN 7 - possibly not necessary but everything was ran with cuDNN so cannot say for sure
- OpenCV 4
- CMake 3.8
- Python3 - and the tqdm module (
pip3 install tqdm
)
git clone https://github.com/AlexeyAB/darknet.git
Set the following options in the Makefile
GPU=1
CUDNN=1
OPENCV=1
LIBSO=1
Then inside the darknet root directory run
mkdir build-release
cd build-release
cmake ..
make
make install
Alternatively just running make
instead may work
To test the build first download a pre-trained weight file
wget https://pjreddie.com/media/files/yolov3.weights
Then run
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
Check the commandline output and the output predictions.jpg file to ensure everything ran as expected.
Place the scripts/get_dataset.py and the scripts/create_configs.py in the darknet/scripts folder
Run this from the darknet root dir
python3 get_dataset.py
Follow the instructions and enter the path to the raw dataset, the proportion of testing and validation sets.
(Recommended: Training - 7, Test - 2, Validation - 1)
The script will do the following:
- Create a training, test and validation folder in darknet/data/Dataset
- Flatten the category labels to be of only one singular class, and remove the cyclist and pedestrain classes.
- Create all of the necessary config files: darknet/cfg/yolov3-custom.cfg, darknet/cfg/custom.data, darknet/cfg/classes.names
First download the darknet53.conv.74 weight file
wget https://pjreddie.com/media/files/darknet53.conv.74
Then start the training using the following command
./darknet detector train cfg/custom.data cfg/yolov3-custom.cfg darknet53.conv.74 -map
Test the model by running
./darknet detector test cfg/custom.data cfg/yolov3-custom.cfg backup/<weightfile>.weights
The weight files are saved in the darknet/backup folder
Place the /scripts/calibrate.py file in the darknet/scripts folder and run
python3 calibrate.py -i <calibration_image_file>
See Vehicle_Speed_Yolo/src/yolo_consol_dll.cpp file.
See Vehicle_Speed_Yolo/src/yolo_consol_dll.cpp file.
These instructions were written up post completion of the project and there may be some missing steps that were forgotten about.
For any issues encountered during the training please see: