How to convert images (.jpg) to vectors for image classification I'm currently working on a project that involves classifying an image as either that of a dog or that of a cat. The twist is that I want to do this without using Convolutional Neural Networks, mainly because I do not quite understand them yet and I don't just want to copy someone's code off of Github. 

I know that the classification algorithms on Sci-Kit Learn require the x input data to be in vectorized form for the classifier to fit the data, but I'm unsure of how to do this. It's easy to do with text data (feature_selection.text.CountVectorizer/TfidfVectorizer), but I have no idea how this works with images. How do I convert .jpg image files to vectors/matrices so that the models on SK-Learn understand it?  

Thanks in advance, and I'm sorry if this is a stupid question.
You can use imread function from imageio library with np.array from numpy:

from imageio import imread
import numpy as np
filename = '/path/to/dog.jpg'
vectorized_picture = np.array(imread(filename))


When entering this data into a ML engine, you'll probably need to reshape it to a column matrix (at least in Prof. Andrew Ng's Coursera Machine Learning courses that I've been doing). If so, you can do that by:

reshaped_vectorized_picture = vectorized_picture.reshape(1, -1).T


You need to install both libraries through apt, brew or pip (preferred one)

pip install numpy imageio