dataset.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:speed 作者: keon 项目源码 文件源码
def get_batcher(self, shuffle=True, augment=True):
        """ produces batch generator """
        w, h = self.resize

        if shuffle: np.random.shuffle(self.data)
        data = iter(self.data)
        while True:
            x = np.zeros((self.batch_size, self.timesteps, h, w, 3))
            y = np.zeros((self.batch_size, 1))
            for b in range(self.batch_size):
                images, label = next(data)
                for t, img_name in enumerate(images):
                    image_path = self.folder + 'images/' + img_name
                    img = cv2.imread(image_path)
                    img = img[190:350, 100:520] # crop
                    if augment:
                        img = aug.augment_image(img) # augmentation
                    img = cv2.resize(img.copy(), (w, h))
                    x[b, t] = img
                y[b] = label
            x = np.transpose(x, [0, 4, 1, 2, 3])
            yield x, y
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号