batches.py 文件源码

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

项目:deep-style-transfer 作者: albertlai 项目源码 文件源码
def load_batches(self):
        """ Load max_batches batches into memory """
        is_new = False
        if self.batches:
            batches = self.batches
        else:
            is_new = True
            batches = []
            self.batches = batches
        image_dir = self.image_dir
        batch_size = self.batch_size
        image_h = self.image_h
        image_w = self.image_w
        file_list = os.listdir(image_dir) if image_dir != DUMMY else []
        n = self.last_load 
        for b in range(self.max_batches):
            if is_new:
                arr = np.zeros((batch_size, image_h, image_w, 3))
                batches.append(arr)
            else:
                arr = batches[b]
            if image_dir != DUMMY:
                i = 0
                while i < batch_size:
                    file_name = file_list[n]
                    try:
                        image = utils.load_image(os.path.join(image_dir,file_name), image_h, image_w)
                        arr[i] = image
                        i += 1
                    except:
                        pass
                    n += 1 if not self.valid else -1
        self.last_load = n
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号