def preprocess_data(img, preprocess_mode, im_sz, data_mode):
if preprocess_mode == 'pad':
if data_mode == 'image':
img = np.pad(img, ((0, im_sz-img.shape[0]), (0, im_sz-img.shape[1]), (0,0)), 'constant', constant_values=(0))
elif data_mode == 'label':
img = np.pad(img, ((0, im_sz-img.shape[0]), (0, im_sz-img.shape[1])), 'constant', constant_values=(0))
else:
print('Invalid data mode.', file=sys.stderr)
elif preprocess_mode == 'res':
img = imresize(img, (im_sz, im_sz), interp='bilinear')
else:
print('Invalid preprocess mode.', file=sys.stderr)
return img
评论列表
文章目录