(tensor: megengine.Tensor, scale=255)
return tensor
normalize image tensors of any range to [0, scale=255]
normalize image tensors of any range to [0, scale=255]
normalize image tensors of any range to [ 0 scale = 255 ]
def normalize_image(tensor: megengine.Tensor, scale=255):
    """normalize image tensors of any range to [0, scale=255]"""
    mi = tensor.min()
    ma = tensor.max()
    tensor = scale * (tensor - mi) / (ma - mi + 1e-9)
    return tensor
def normalize_image ( tensor : megengine . Tensor , scale = 255 ) : mi = tensor . min ( ) ma = tensor . max ( ) tensor = scale * ( tensor - mi ) / ( ma - mi + 1e-9 ) return tensor