我发现我们现在不能直接从Pytorch下载ImageNet数据集。我得到了这个错误:
RuntimeError: The dataset is no longer publicly accessible. You need to download the archives externally and place them in the root directory.
所以我在网站上下载了32X32
镜像(为什么下载这么慢?)。所以它批量下载训练数据,当我加载其中一个并查看图像的外观时,我得到了这样的结果:
下面是我加载图像的方式:
file_1 = np.load("imagenet/Imagenet32_train_npz/train_data_batch_1.npz")
img = file_1['data'][0]
img = np.reshape(img, (32,32,3))
plt.imshow(img)
plt.show()
是我做错了什么,还是ImageNet只是改变了?让我知道。
发布于 2021-07-19 02:30:17
我也遇到过同样的问题,我知道imagenet数据是通道优先的,这意味着不是将其重塑为(32,32,3),而是将其重塑为(3,32,32),然后转置它,完整的代码将如下所示:
file_1 = np.load("yourpath" , allow_pickle=True)
images = file_1["data"].reshape(-1 , 3 , 32 , 32)
images = images.transpose(0 , -2 , -1 , 1)
https://stackoverflow.com/questions/66948436
复制相似问题