-
-
Save zhanwenchen/86c98df8a54cda047a43bd5c7fb88f66 to your computer and use it in GitHub Desktop.
PyTorch Torchvision UnNormalize (reverse Normalize)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torchvision | |
class UnNormalize(torchvision.transforms.Normalize): | |
def __init__(self,mean,std,*args,**kwargs): | |
new_mean = [-m/s for m,s in zip(mean,std)] | |
new_std = [1/s for s in std] | |
super().__init__(new_mean, new_std, *args, **kwargs) | |
# imagenet_norm = dict(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225]) | |
# UnNormalize(**imagenet_norm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment