Python emnist训练数据集中的字母是旋转的,几乎不模糊

Python emnist训练数据集中的字母是旋转的,几乎不模糊,python,machine-learning,dataset,Python,Machine Learning,Dataset,我使用的是emnist-letters-train-images-idx3-ubyte.gz和emnist-letters-train-labels-idx1-ubyte.gz 我写这个小脚本是为了看图像 导入操作系统 导入结构 将numpy作为np导入 导入scipy.misc np.set_打印选项(threshold='nan') 路径='。/' fname_img=os.path.join(路径“emnist-letters-train-images-idx3-ubyte”) fname

我使用的是
emnist-letters-train-images-idx3-ubyte.gz和emnist-letters-train-labels-idx1-ubyte.gz 我写这个小脚本是为了看图像

导入操作系统
导入结构
将numpy作为np导入
导入scipy.misc
np.set_打印选项(threshold='nan')
路径='。/'
fname_img=os.path.join(路径“emnist-letters-train-images-idx3-ubyte”)
fname_lbl=os.path.join(路径“emnist-letters-train-labels-idx1-ubyte”)
开放式(fname_lbl,'rb')作为flbl:
magic,num=struct.unpack(“>II”,flbl.read(8))
lbl=np.fromfile(flbl,dtype=np.int8)
将open(fname_img,'rb')作为fimg:
magic,num,rows,cols=struct.unpack(“>IIII”,fimg.read(16))
img=np.fromfile(fimg,dtype=np.uint8)。重塑(len(lbl),rows,cols)
打印“图像”,img.shape
打印“标签”,lbl.shape
标签,索引=np.unique(lbl,返回值\索引=True)
打印“唯一标签”,标签
打印“唯一索引”,索引
对于指数中的i:
图像=img[i]
对于图像中的y:
row=“”
对于y中的x:

行+='{0:水平翻转图像,然后逆时针旋转90度。

水平翻转图像,然后逆时针旋转90度。

正如Ankit Tiwari所说。 在水平翻转和旋转后,它看起来还可以。 谢谢 参见Ankit Tiwari所说的。 在水平翻转和旋转后,它看起来还可以。 谢谢
请参见

此处的问题可能是您读取数据集数组的方式。如果您转置正在读取的数组(例如,对于numpy数组,
您的_数组.T
),则您的EMNIST字符应该位于正确的方向。

此处的问题可能是您读取数据集数组的方式。如果您转置正在读取的数组(例如,对于numpy数组,
您的_array.T
),您的EMNIST字符应该位于正确的方向。

这在Ubuntu 16.04/Anaconda 3.6中有效,尽管Python 2只是注释输出打印…验证EMNIST平衡和MNIST加载的快速方法

这在Ubuntu 16.04/Anaconda 3.6中有效,尽管Python 2只是注释输出打印…验证EMNIST平衡和MN的快速方法IST正在加载代码片段以转换pytorch中的eminst(仅查看是否需要转换)


pytorch中转换eminst的代码段(仅查看必要的转换)


我认为你应该将数据逆时针旋转90度。一些图像可以,但不是全部。我认为你应该将数据逆时针旋转90度。一些图像可以,但不是全部。
dataset = torchvision.datasets.EMNIST(
                path_data,
                download=True,
                split='balanced',
                train=not is_test_data,
                transform=torchvision.transforms.Compose([
                    lambda img: torchvision.transforms.functional.rotate(img, -90),
                    lambda img: torchvision.transforms.functional.hflip(img),
                    torchvision.transforms.ToTensor()
                ])
            )