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