Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created December 10, 2021 02:20
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 e96031413/634dd935b922fc4aef734a563131d6d6 to your computer and use it in GitHub Desktop.
Save e96031413/634dd935b922fc4aef734a563131d6d6 to your computer and use it in GitHub Desktop.
從PyTorch的Tensor資料中,將資料保存成實體圖片檔案
from torchvision.utils import save_image
features, imgs, labels, image_path = get_features_trained_weight(model, transform_dataset)
img1 = imgs[1] #第1張圖片
img1 = torch.from_numpy(img1) #格式轉換
save_image(img1, 'img1.png') #保存成'img1.png'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment