Skip to content

Instantly share code, notes, and snippets.

@Paulescu
Last active June 27, 2022 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paulescu/33baf2d3119ae63cef38f62e9f98969e to your computer and use it in GitHub Desktop.
Save Paulescu/33baf2d3119ae63cef38f62e9f98969e to your computer and use it in GitHub Desktop.
import torch
from torch import Tensor
from torchvision import transforms
def inverse_feature_extractor(x: Tensor):
""""""
t = x.squeeze(0)
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
t = t.mul(torch.FloatTensor(std).view(3,1,1)).add(torch.FloatTensor(mean).view(3,1,1)) #.numpy()
im = transforms.ToPILImage()(t)
return im
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment