3
votes

I have a bunch of training images (.jpg format) that I want to give as training input to scikit learn's SVM classifier. Any idea what's the preferred way to doing this?

For example, in the example here the image data is loaded from a predefined set and converted to a format that the SVM classifier understands in the following steps.

# The digits dataset
digits = datasets.load_digits()

# To apply an classifier on this data, we need to flatten the image, to
# turn the data in a (samples, feature) matrix:
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))

My question is if I've my own set of images that I want to load as a training set to the SVM classifier how should I go about converting those images into a format that the classifier will understand.

My developing on OS-X (Mavericks) but I'll run the actual code on Linux (Ubuntu)

Thanks

2
You want shell scripts? Python scripts? What is your OS? - jb.
I don't want shell scripts. I'm coding in python on OS-X (Mavericks). - Soumya Simanta

2 Answers

1
votes

You could use DeCAF / nolearn / convnet for this task. See this page for an example.

0
votes

Why not use standard python libraries for working with images, like PIL or it's fork Pillow. It should be straightforward to obtain numpy arrays of bytes from that.

As for feature extraction I guess Thorsten has better tools.