import os
import cv2
import numpy
as np
from tqdm
import tqdm
def read_image(path
):
'''读取路径下所有子文件夹中的图片并存入list'''
img_list
= []
label_list
= []
dir_counter
= 0
for child_dir
in os
.listdir
(path
):
child_path
= os
.path
.join
(path
, child_dir
)
for dir_image
in tqdm
(os
.listdir
(child_path
)):
img
= cv2
.imread
(child_path
+"\\"+dir_image
,cv2
.IMREAD_COLOR
)
img_list
.append
(img
)
label_list
.append
(dir_counter
)
dir_counter
+= 1
return img_list
,label_list
,dir_counter
转载请注明原文地址: https://www.6miu.com/read-5038496.html