How i can convert a image into an mnist type image as the usual image is of shape (28,28,3 ) whereas mnist image if of shape(28,28)

sir when i try toa apply mnist digit congnition project onto other images than the mnist_test the result donot come as expected. kindly tell me what to do?

Hey @abubakar_nsit, first of all you need to load the image the image in grayscale mode, by using img = cv2.imread(img_path, 0) . Than you will get the image as 28,28

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

sir why self captured images donot work work with mnist classification digit recognition?

Hey @abubakar_nsit, it depends on model training, you can’t teach a student about ‘science’ and make him to give test on ‘social science’. So our model was trained on gray scale images, we can’t force it to classify rgb image.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

doesn’t img=cv2.imread(img_path, 0) converts the image into gray scale images?
if yes, then why it doesnot work in mnist digit classification and if no, please sir tell me how i can convert self captured image into suitable form for mnsit digit classification program?

Hey @abubakar_nsit, yes it converts into gray scale. It doesn’t work on mnist digit classifier because in mnist datasets images, digits are painted with 0 and rest all background is black. So make sure you input image should be of similar kind only. One easy hack is to colour convert the images, by img = 255.0 - img. This would change black to white and white to black. But it may or may not produce good results.

Otherwise, make your own new dataset, and train your model on that, and than use it.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush: