A simple Python project to compare two popular computer vision models for pedestrian detection: Histogram of Oriented Gradients (HoG) and Faster R-CNN.
- Loads all images from the Penn Fudan Pedestrian dataset
- Detects pedestrians using:
- HoG + SVM (OpenCV)
- Faster R-CNN (PyTorch/Torchvision)
- Visualises detection results with bounding boxes
- Python 3.x
- OpenCV
- scikit-image
- PyTorch
- Torchvision
-
Install dependencies:
pip install opencv-python scikit-image torch torchvision
-
Download the Penn Fudan Pedestrian dataset and place it in a folder, e.g.
c:/path/to/PennFudanPed/PNGImages
. -
Update the
images_folder
variable at the top of bothHoG Model.py
andFaster R-CNN Model.py
to the path where your dataset images are stored:images_folder = 'c:/path/to/PennFudanPed/PNGImages' # Update this path as needed
-
Run the HoG model:
python "HoG Model.py"
-
Run the Faster R-CNN model:
python "Faster R-CNN Model.py"
Each script will process and display the detection results for every image in the dataset folder.
- Ensure the dataset path is correct in both scripts.
- The HoG model uses greyscale images and classical feature-based detection.
- The Faster R-CNN model uses a deep learning approach and may require a GPU for faster inference.
- Results may vary depending on the image and environment.