Python Implementation of Bag of Words for Image Recongnition using OpenCV and sklearn
This is a clean fork of bikz05's work.
Dependencies:
- Python (>= 3.3)
- Numpy (>= 1.6.1)
- Scipy (>= 0.9)
- Scikit Learn
I am using OpenCV3 and a number of things have been moved to the opencv_contrib repo. Make sure you install the xfeatures2d module to be able to use SIFT.
python learn.py -t dataset/train -c dataset/model
- Testing a single image
python predict.py -t dataset/test/class/image.extension --show
- Testing a testing dataset
python predict.py -t ../dataset/test/ -m ../dataset/model -r ../dataset/results --verbose
The --visualize
flag will display the image with the corresponding label printed on the image/
If you get
AttributeError: 'LinearSVC' object has no attribute 'classes_'
error, the simply retrain the model.