Detectron2 is a framework written on Pytorch that helps training an object detection model in a snap with a custon dataset. It presents multiple models model zoo trained on coco dataset so we just need to fine tune our custom dataset on one of the pre-trained model.
In this repository, we are going to deal with identifying empty and occupied parking lots using Faster RCNN model from detectron2 model zoo: The faster_rcnn_R_50_FPN_3x
To train detectron2 we need to follow these steps:
- Install detectron2
- Prepare and register the dataset
For our case, we are using PKLot dataset. The dataset is downloaded in a coco format from Roboflow - Train the model
Training is done on GPU. It takes around 1.88 s/iter (around 47 min for the whole training)
The training curves are visualised using tensorboard:
You can download the trained model from - Inference using the trained model
Here are some results:
Usually, the model is evaluated following the COCO Standards of evaluation. Mean Average Precision (mAP) is used to evaluate the performance of the model.
We get an accuracy of around 94.69% for an IoU of 0.5 and around 88.93% for an IoU of 0.75 which is not bad!
python>=3.6
torch==1.3.0+cu100
torchvision==0.4.1+cu100
tensorboard
cython
jupyter
scikit-image
numpy
opencv-python
pycocotools
pyyaml==5.1
# Install detectron2 that matches the above pytorch version
# See https://detectron2.readthedocs.io/tutorials/install.html for instructions
pip install detectron2
cd .\Detection-using-Detectron2
curl -L "https://public.roboflow.com/ds/gPbookuOTI?key=kfody3xy1u" > roboflow.zip; unzip roboflow.zip; rm roboflow.zip --output /content/sample_data/
Please dowload from Google Drive and put in .\Detection-using-Detectron2
python Pklot.py --mode train
python Pklot.py --mode test
You can also check Colab for other application of detectron2 (training a balloon segmentation model).