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
评论列表
文章目录