Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
從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