Given an input image which may contain multiple pedestrians, a pedestrian detection system detects each person and returns a bounding box for each detection
This repo uses OpenCV to do template tracking using 2 methods:
-
HoG Method:
-
Firstly, we use a pretrained HoG detector (trained on the INRIA dataset as per the original paper Histograms of Oriented Gradients for Human Detection). For this, we use OpenCV’s HOGDescriptor() with getDefaultPeopleDetector()
-
Next, we extract HoG features using skimage's HoG feature extractor and train our own SVM classifier on top of it. For this, prepare the training data with positive and negative samples for SVM.
-
-
Faster-RCNN Method: Here, we use the pre-trained Faster-RCNN detector (as described in Faster r-cnn: Towards real-time object detection with region proposal networks).
- We implenmted PyTorch's implementation of Faster-RCNN. Here's a link to PyTorch Faster-RCNN Tutorial
- The pre-trained model detects multiple object categories, but we are only concerned with the ‘person’ category. Since we used a model trained on the COCO dataset, we only needed the predictions for class label 1, which corresponds to the ‘person’ category
The dataset used is "PennFudanPed" and can be downloaded from here and can be stored in PennFudanPed folder
- Download PennFudanPed dataset and put in PennFudanPed folder
- Install required python packages using:
pip install -r requirements.txt
-
Run any of the three scripts using the corresponding command:
-
hog_pretrained.py :
python hog_pretrained.py -i PennFudanPed --vis
, -
hog_custom.py :
python hog_custom.py -i PennFudanPed --vis
, -
faster_rcnn.py :
python faster_rcnn.py -i PennFudanPed --vis
,
where -i is dataset folder path. Add --vis to visualize detections
-
-
The following metrics have been provided for evaluation:
- Average Precision (AP): AP evaluated and averaged over 10 IoU thresholds of .50:.05:.95
- Average Recall (AR): AR averaged over IoUs and evaluated at 1 and 10 detections per image.
-
Results can be evaluated using evaluation script provided. Use the command:
python evaluate_detections.py --gt <path to ground truth annotations json> --pred <path to detections json>