Skip to content

Commit

Permalink
AlexNet_Pytorch_Cifar-10读取
Browse files Browse the repository at this point in the history
  • Loading branch information
MansourGu committed Oct 21, 2022
1 parent b5e3dd8 commit 6a5864a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions AlexNet/DataLoader_Pytorch_Cifar-10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np
import cv2 as cv
file_path = 'E:/Code/DataSet/cifar-10-batches-py/data_batch_1'
def unpickle(file):
import pickle
with open(file, 'rb') as fo:
dict = pickle.load(fo, encoding='bytes')
return dict

def Load_Cifar_10_Batch(file_path):
batch_dict = unpickle(file_path)


dict = unpickle(file_path)
pictures = dict[b'data']
pic = pictures.reshape(10000, 3, 32, 32)[0]
print(pic.shape)
pic = np.transpose(pic, (1, 2, 0))

cv.imshow('修改后', pic)
cv.waitKey(0)

0 comments on commit 6a5864a

Please sign in to comment.