i=0 dir_fold="E:/1深度学习/cifar-100/imag/mini-imagenet/100/mini-imagenet/images" dir_fold1="E:/1深度学习/cifar-100/imag/mini-imagenet/100/mini-imagenet/train/" with open('train.csv', 'r') as f: reader = csv.reader(f) sum=0 for row in reader: if sum!=0: photo = dir_fold + "/" + row[0] im = Image.open(photo) photo_new=dir_fold1+row[1] im.save(photo_new+"/"+row[0]) i=i+1 print(i) sum=sum+1 with open('val.csv', 'r') as f: reader = csv.reader(f) sum=0 for row in reader: if sum!=0: photo = dir_fold + "/" + row[0] im = Image.open(photo) photo_new=dir_fold1+row[1] im.save(photo_new+"/"+row[0]) i=i+1 print(i) sum=sum+1 with open('test.csv', 'r') as f: reader = csv.reader(f) sum=0 for row in reader: if sum!=0: photo = dir_fold + "/" + row[0] im = Image.open(photo) photo_new=dir_fold1+row[1] im.save(photo_new+"/"+row[0]) i=i+1 print(i) sum=sum+1
标签:存于,读取,photo,sum,文件夹,im,reader,dir,row From: https://www.cnblogs.com/hahaah/p/16584452.html