I want to analyze my own images using an SVM trained on the MNIST dataset. How can I preprocessed my image so it can be accepted by the model?
dataset = datasets.fetch_openml("mnist_784", version=1)
(trainX, testX, trainY, testY) = train_test_split(
dataset.data / 255.0, dataset.target.astype("int0"), test_size = 0.33)
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dataset", type=str, default="3scenes",
help="path to directory containing the '3scenes' dataset")
ap.add_argument("-m", "--model", type=str, default="knn",
help="type of python machine learning model to use")
args = vars(ap.parse_args())
#user input image to classify
userImage = cv.imread('path_to_image/1.jpg')
#preprocess user image
#...
models = {
"svm": SVC(kernel="linear"),
}
# train the model
print("[INFO] using '{}' model".format(args["model"]))
model = models[args["model"]]
model.fit(trainX, trainY)
print("[INFO] evaluating image...")
predictions = model.predict(userImage)
print(classification_report(userImage, predictions))