def reader(path, shuffle=True):
files = []
for img_file in os.scandir(path):
if img_file.name.lower().endswith('.jpg', ) and img_file.is_file():
files.append(img_file.path)
if shuffle:
# Shuffle the ordering of all image files in order to guarantee
# random ordering of the images with respect to label in the
# saved TFRecord files. Make the randomization repeatable.
shuffled_index = list(range(len(files)))
random.shuffle(files)
files = [files[i] for i in shuffled_index]
return files
评论列表
文章目录