首页 > 其他 > 详细

文件夹自动标号分类

时间:2018-05-30 11:57:18      阅读:256      评论:0      收藏:0      [点我收藏+]
def read_img(path):
    imgs = []
    labels = []
    # classs = []
    classs = os.listdir(path)

    for idx, folder in enumerate(classs):
        cate = os.path.join(path, folder)
        for im in os.listdir(cate):
            print(im)
            img_path =os.path.join(cate, im)
            print(reading the images:%s % (img_path))
            img = io.imread(img_path)
            img = transform.resize(img, (w, h))
            # with open(‘tests.txt‘, ‘a‘) as f:
            #     f.write(img_path+‘_‘+str(idx)+‘\n‘)
            imgs.append(img)
            labels.append(idx)
    return np.asarray(imgs, np.float32), np.asarray(labels, np.int32)

 

文件夹自动标号分类

原文:https://www.cnblogs.com/ansang/p/9110047.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!