Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用Python中的MNIST方式为图像分类准备/渲染图像_Python_Python 3.x_Image_Rendering_Image Classification - Fatal编程技术网

用Python中的MNIST方式为图像分类准备/渲染图像

用Python中的MNIST方式为图像分类准备/渲染图像,python,python-3.x,image,rendering,image-classification,Python,Python 3.x,Image,Rendering,Image Classification,我知道以前有人问过这个问题,但我仍然面临一些问题 在建立了神经网络并训练了模型之后,我现在想对桌面上的图像进行分类。因此,在监督学习之前必须准备好图像 如何将普通图片转换为格式(1、28、28) 我试着这样做 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) 任何想法、灵感… 提前感谢您不

我知道以前有人问过这个问题,但我仍然面临一些问题

在建立了神经网络并训练了模型之后,我现在想对桌面上的图像进行分类。因此,在监督学习之前必须准备好图像

如何将普通图片转换为格式(1、28、28)

我试着这样做

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)
任何想法、灵感…
提前感谢您

不要使用
imageio
库,您可以使用OpenCV,这是
cv2
库(需要先安装)


真棒这是一个简单而快速的解决方案,Thx Omar;)
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)