cifar-10 图片查看

cifar10 图片查看器

from PIL import Image

def unpickle(file):
    import pickle
    with open(file, 'rb') as fo:
        dict = pickle.load(fo, encoding='bytes')
    return dict

import matplotlib.pyplot as plt
import numpy as np

def DataPrepare(strpath):
    X = []
    L = []
    for i in range(1, 5):
        data = unpickle(strpath +'/data_batch_' + str(i))
        data = data[b'data'].reshape(10000, 3, 32, 32)
        for j in range(10000):
            imgdata = data[j, :, :, :]
            plt.cla()
            plt.imshow(np.transpose(imgdata, (1, 2, 0)))
            plt.pause(0.1)


if __name__ == '__main__':
	# cifar10 解压的路径
	strpath = 'D:\pytorch_DPSH/data/CIFAR-10/data/cifar-10-batches-mat'
    DataPrepare()

你可能感兴趣的:(深度学习)