<jupyter_start><jupyter_text>model_path = '../data/p1ch2/horse2zebra_0.4.0.pth' model_data = torch.load(model_path) netG.load_state_dict(model_data)<jupyter_code>from torchvision import models
import torch
netG = ResNetGenerator()
weight_path = '/Users/mnctty/Desktop/DL with Pytorch/1_lessons/horse2zebra_0.4.0.pth'
model_data = torch.load(weight_path)
#model_data.keys()
netG.load_state_dict(model_data)
### а что еще можно загрузить?
netG.eval()
from PIL import Image
from torchvision import transforms
preprocess = transforms.Compose([transforms.Resize(256),
transforms.ToTensor()])
img_path = '/Users/mnctty/Desktop/DL with Pytorch/1_lessons/horses.jpeg'
img = Image.open(img_path)
img.show()
img_transformed = preprocess(img)
batch_tensor = torch.unsqueeze(img_transformed, 0)
res = netG(batch_tensor)
res.show()
out_t = (res.data.squeeze() + 1.0) / 2.0 
out_img = transforms.ToPILImage()(out_t)
out_img
out_img.save('/Users/mnctty/Desktop/DL with Pytorch/1_lessons/zebhorses.jpg')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup