datasets.py 文件源码

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

项目:torchsample 作者: ncullen93 项目源码 文件源码
def default_file_reader(x):
    def pil_loader(path):
        return Image.open(path).convert('RGB')
    def npy_loader(path):
        return np.load(path)
    def nifti_loader(path):
        return nibabel.load(path).get_data()
    if isinstance(x, str):
        if x.endswith('.npy'):
            x = npy_loader(x)
        elif x.endsiwth('.nii.gz'):
            x = nifti_loader(x)
        else:
            try:
                x = pil_loader(x)
            except:
                raise ValueError('File Format is not supported')
    #else:
        #raise ValueError('x should be string, but got %s' % type(x))
    return x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号