cifar-10 이미지 보기

5320 단어 딥 러닝
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()

좋은 웹페이지 즐겨찾기