ymdatta / BagOfVisualWords

Image categorization using Bag of visual words approach.
MIT License
4 stars 2 forks source link
bag-of-visual-words computer-vision object-recognition

BagOfVisualWords

Image categorization using Bag of visual words approach.

Uses opencv python-contrib SIFT for feature extraction and scikit-learn's SVM.

This is python implementation of Bag of visual words model, which again is based on the paper by Csurka et al[1].

Please refer here, for details regarding implementation of the model.

Things you need to install before running:

Project architecture:

  -BagOfVisualWords/
        |- images/
                  |-train/
                          |-category 1
                          |-category 2
                          |-etc
                  |-test/
                          |-category 1
                          |-category 2
                          |-etc
                  |-kmeans/
                          |-category 1
                          |-category 2
                          |-etc
        |- bag_of_words.py
        |- read_files.py
        |- plot_data.py
        |- all other python and sav files.
Things to remember before running:
  1. Change the path to images in the read_files.py file, to point to the directory containing test, train, kmeans images.

  2. Change the path in the KMeans_clustering.py to point to the directory containing kmeans images.

Usage:

python bag_of_words.py

Additional Information:

Results:

Number of categories Accuracy No of clusters used
3 83% 600
3 85% 800
4 76% 600
4 76% 800
5 81% 600
5 80% 800
6 67% 600
6 67% 600

Confusion Matrix.

Documentation:

References:

Feel free to open an Issue if you face any problem. :)