writer.py 文件源码

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

项目:nuts-ml 作者: maet3608 项目源码 文件源码
def __call__(self, sample):
        """Return sample and write image within sample"""
        pathfunc, namefunc = self.pathfunc, self.namefunc
        name = namefunc(sample) if isfunction(namefunc) else next(namefunc)

        if isinstance(pathfunc, str):
            filepath = pathfunc.replace('*', str(name))
        elif isfunction(pathfunc):
            filepath = pathfunc(sample, name)
        else:
            raise ValueError('Expect path or function: ' + str(pathfunc))

        create_folders(os.path.split(filepath)[0])
        img = sample if self.column is None else sample[self.column]
        sio.imsave(filepath, img)
        return sample
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号