pytorch本地图片数据集加载成字典

from torchvision.transforms import transforms
import pandas as pd

file_path=os.path.join(r'E:\python存储\leaves\images')
Image_list=[]
labels_list=[]
a={}

for i in range(0,18352):
    image_path=os.path.join(r'E:\python存储\leaves\images','{}.jpg'.format(i))
    image=Image.open(image_path)
    trans=transforms.ToTensor()
    Image_list.append(trans(image))

train_label_read=pd.read_csv(r'E:\python存储\leaves\train.csv')
train_label=train_label_read['label']
dataset=dict(map(lambda x,y:[x,y],train_label,Image_list))
print(dataset)
上一篇:LIBTORCH C++


下一篇:[每日一题]: poj 3321 Apple Tree