Object Detector using HOG as descriptor and Linear SVM as classifier
Install OpenCV 3 with Python 3 bindings
You can install all dependencies by running
pip install -r requirements.txt
To test the code, run the lines below in your terminal
git clone https://github.com/vladkha/object_detector.git
cd object_detector/bin
python test_object_detector.py
The test_object_detector.py
will download the
CelebA and WIDER FACE
datasets and train a classifier to detect faces in an image.
The SVM model files will be stored in data/models
,
so that they can be reused later on in test_classifier.py
All the configurations are in the data/config/config.cfg
configuration files.
You can change it as per your need.
Here is what the default configuration file looks like
[hog]
window_size: [178, 218]
window_step_size: 20
orientations: 9
pixels_per_cell: [8, 8]
cells_per_block: [3, 3]
visualise: False
normalise: None
[nms]
threshold: 0.4
[paths]
model_path: ../data/models/model_name.model
[general]
pyramid_downscale = 1.5
pos_samples = 1000
neg_samples = 1000
config.py
-- imports the configuration variables fromconfig.cfg
create_neg_samples_WIDER.py
-- module to create negative samples (images of non-faces from WIDER dataset)extract_features.py
-- module used to extract HOG features of the training imagestrain_classifier.py
-- module used to train the classifiertest_classifier.py
-- module used to test the classifier using a test imageutils.py
-- module containing helper functions
Detections before NMS | Detections after NMS |
---|---|
- OpenCV 3 - Computer vision library
- Scikit-learn - Machine learning library
- scikit-image - Image processing library
Possible ways to improve the project:
- Make the sliding window computation run in parallel - can dramatically speedup the code
- Split processing of the image pyramid in
test_classifier.py
to different cores of the processor, that way each core can process a separate layer of the pyramid independently - Add bootstrapping (Hard Negative Mining)
- Credit for base project structure and image processing goes bikz05 for his object-detector
- Adrian Rosebrock for his great blog www.pyimagesearch.com and particular series of articles regarding object detection topic:
- Histogram of Oriented Gradients and Object Detection
- Non-Maximum Suppression for Object Detection in Python
- (Faster) Non-Maximum Suppression in Python
- Intersection over Union (IoU) for object detection
- Image Pyramids with Python and OpenCV
- Sliding Windows for Object Detection with Python and OpenCV
- Pedestrian Detection OpenCV
- HOG detectMultiScale parameters explained
This project is licensed under the MIT License - see the LICENSE file for details