在 Python 中使用 MNIST FASHION 为图像分类准备/渲染图像
Preparing / Rendering Image for Image Classification with MNIST FASHION in Python
我知道以前有人问过这个问题,但我仍然遇到一些问题。
设置神经元网络并训练模型后,我现在想对桌面上的图像进行分类。因此,图像必须在监督学习之前准备好……
如何将普通图片转换成格式(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
库(需要先安装)。
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)
我知道以前有人问过这个问题,但我仍然遇到一些问题。
设置神经元网络并训练模型后,我现在想对桌面上的图像进行分类。因此,图像必须在监督学习之前准备好……
如何将普通图片转换成格式(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
库(需要先安装)。
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)