import os
import csv
def create_csv(labels):
path = '/Users/Desktop/pic/training/apple'
name = os.listdir(path)
with open(path + '.csv', 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['data', 'label'])
for n in name:
if n[-4:] == '.jpg':
print(n)
writer.writerow(['/Users/Desktop/pic/training/' + str(labels) + '/' + str(n),'/Users/Desktop/pic/training/' + str(labels) + 'label/' + str( n[:-4] + '.png')])
else:
pass
if __name__ == "__main__":
create_csv('testing')
create_csv('training')
深度学习
导入图片加载器还是错误,在AI-BAIDU中下载了fruits数据集,因为没有CSV无法加载图片,待解决