This repository goes through the process of setting up Darkflow, and using it to train a custom object detection model. Here, I have trained a Car Damage Detection model, that identifies Scratches and Dents and draws a bounding box around it.
The dataset can be downloaded from here.
Training.ipynb contains the source code, and the trained model weights (checkpoint files) are available in the checkpoints folder.
-
Create a new Python/Anaconda enviroment (optional but recommended).
-
Install the necessary packages:-
conda install numpy pandas matplotlib opencv cython jupyter
- If you have a supported GPU, run
conda install tensorflow-gpu=1.14
- If you don't have a supported GPU or want to train on a CPU, run
conda install tensorflow=1.14
-
Clone the Darkflow repository into your working directory and run
cd darkflow
. -
Setup darkflow and build the Cython extensions.
pip install .
python setup.py build_ext --inplace
-
Download the yolo weights from here and again place in the working directory. More info in the .ipynb file.
-
From the Object Detection Metrics repository, download and copy the following into the working directory:-
- pascalvoc.py
- _init_paths.py
- lib module
-
Download the dataset and place it in the following manner:-
├─── darkflow ├─── .. ├─── .. ├─── cfg ├─── checkpoints ├─── lib ├─── test_imgs ├─── pascalvoc.py ├─── _init_paths.py ├─── labels.txt ├─── Training.ipynb ├─── yolo.weights └─── data ├─── annotations ├─── annot1.xml ├─── annot2.xml ├─── annot3.xml ├─── annot5.xml ├─── annot6.xml ├─── .. ├─── .. └─── .. └─── images ├─── img1.jpg ├─── img2.jpg ├─── img3.jpg ├─── img4.jpg ├─── img5.jpg ├─── .. ├─── .. └─── ..
- https://github.com/thtrieu/darkflow
- https://github.com/pjreddie/darknet
- https://towardsdatascience.com/yolov2-to-detect-your-own-objects-soccer-ball-using-darkflow-a4f98d5ce5bf
- https://github.com/deep-diver/Soccer-Ball-Detection-YOLOv2
- https://github.com/deep-diver/Object-Detection-YOLOv2-Darkflow
- https://medium.com/@jonathan_hui/map-mean-average-precision-for-object-detection-45c121a31173
- https://github.com/rafaelpadilla/Object-Detection-Metrics