赞
踩
source_image = imageio.imread(opt.source_image)
# 加入以下这句,在之后转化tensor时就不用归一化了,不然直接转换tensor,数值在[0,255]之间,
source_image = resize(source_image, opt.img_shape)[..., :3]
source_image = torch.tensor(source_image[np.newaxis].astype(np.float32)).permute(0, 3, 1, 2)
看到skimage.transform.resize的源码
def resize(image, output_shape, order=1, mode='reflect', cval=0, clip=True,
preserve_range=False, anti_aliasing=True, anti_aliasing_sigma=None):
preserve_range : bool, optional
Whether to keep the original range of values. Otherwise, the input
image is converted according to the conventions of `img_as_float`.
Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
通过设置preserve_range=True就可以保持原来的模式了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。