Skip to content

VladKha/object_detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

object_detector

Object Detector using HOG as descriptor and Linear SVM as classifier

Prerequisites

Install OpenCV 3 with Python 3 bindings

Dependencies

You can install all dependencies by running

pip install -r requirements.txt

Run the code

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

Configuration File

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

About modules

  • config.py -- imports the configuration variables from config.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 images
  • train_classifier.py -- module used to train the classifier
  • test_classifier.py -- module used to test the classifier using a test image
  • utils.py -- module containing helper functions

Some results

Detections before NMS Detections after NMS

Built With

TODO

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)

Acknowledgments

License

This project is licensed under the MIT License - see the LICENSE file for details