Eamonn

人生苦短,我用Python

· tensorflow · · 308次浏览

tensorflow导入图片地址

import random
import pathlib

data_path = pathlib.Path(r'W:\Tf2\pic2')
all_image_paths = list(data_path.glob('.\*.jpg'))  #所有尾缀为.jpg的文件
all_image_paths = [str(path) for path in all_image_paths]  # 所有图片路径的列表
random.shuffle(all_image_paths)  # 打散
print(all_image_paths)

image_count = len(all_image_paths)
print(image_count)
评论 (0条)