Skip to content

WidedCHERIF/Parking-occupancy-detection-using-detectron2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Detection using detectron2

Open In Colab
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
model
To train detectron2 we need to follow these steps:

  1. Install detectron2
  2. Prepare and register the dataset
    For our case, we are using PKLot dataset. The dataset is downloaded in a coco format from Roboflow
  3. 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:
    plot1 plot2 plot3
    You can download the trained model from
  4. Inference using the trained model
    Here are some results:
    Res1 Res2
    Res3
    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!
    Eval

Dependences

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

# Install detectron2 that matches the above pytorch version
# See https://detectron2.readthedocs.io/tutorials/install.html for instructions
pip install detectron2 

Download Dataset

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/

Trained Model

Please dowload from Google Drive and put in .\Detection-using-Detectron2

Train

python Pklot.py --mode train

Test

python Pklot.py --mode test

You can also check Colab for other application of detectron2 (training a balloon segmentation model).

About

Training and testing detectron2 on custom dataset

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages