其他分享
首页 > 其他分享> > 读取文件所有图片存于不同文件夹

读取文件所有图片存于不同文件夹

作者:互联网

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
来源: https://www.cnblogs.com/hahaah/p/16584452.html