I know this question has previously been asked, but I still face some problems.
Having set up the Neuronal Network and trained the model, I now would like classificate images from my Desktop. For this reason the images gotta prepared before the supervised learning…
How can I transform a normal picture into the format (1, 28, 28) ?
I tried doing so by
Img = imageio.imread(f‘path/pic.png‘)
Image = numpy.expand(Img, 0)
Print(Image.shape) RETURNS (1, 28, 28, 3) and NOT (1, 28, 28)
Any Ideas, Inspirations, … Thanks in Advance
Instead of using the imageio
library, you can instead use OpenCV, which is the cv2
library (needs to be installed first).
import numpy as np
import cv2
Img = cv2.imread('path/pic.png', 0) # Need to pass in the zero as a flag to be read in gray-scale
Image = np.expand_dims(Img, 0)
print(Image.shape)
> (1, m, n)