【代码】图像进入网络传播前的归一化

图像需要在通过网络传播之前进行归一化

def normalize(image: np.ndarray) -> np.ndarray:

    image = image.astype(np.float32)
    mean = (0.485, 0.456, 0.406)
    std = (0.229, 0.224, 0.225)
    image /= 255.0
    image -= mean
    image /= std
    return image

猜你喜欢

转载自blog.csdn.net/weixin_45392674/article/details/126421748