def re_normalize(inp: np.ndarray, low: int = 0, high: int = 255 ): """Normalize the data to a certain range. Default: [0-255]""" inp_out = bytescale(inp, low=low, high=high) return inp_out
def re_normalize(inp: np.ndarray, low: int = 0, high: int = 255): inp_out = bytescale(inp, low=low, high=high) return inp_out
print("Original Values: ", digits.target[n_samples // 2:(n_samples // 2) + 5]) plt.show() #Install Pillow library #from PIL #from scipy.misc import imread , imresize, bytescale from sklearn.externals._pilutil import imresize, imread, bytescale img = imread("three.jpeg") img = imresize(img, (8, 8)) classifier = svm.SVC(gamma=0.001) classifier.fit(imageData[:], digits.target[:]) img = img.astype(digits.images.dtype) img = bytescale(img, high=16.0, low=0) print("img.shape : ", img.shape) print("\n", img) x_testData = [] for row in img: for col in row: x_testData.append(sum(col) / 3.0) print("x_testData: \n", x_testData) print("len(x_testData):", len(x_testData)) x_testData = [x_testData] print("len(x_testData) : ", len(x_testData)) result = classifier.predict(x_testData)