GoodWin/Deep-Multi-scale
0
1from .base_model import BaseModel2from . import networks3import torch4import numpy as np5import torchvision.transforms as transforms6import PIL7 8import torch.nn.functional as F9 10class TestModel(BaseModel):11 def name(self):12 return 'TestModel'13 14 @staticmethod15 def modify_commandline_options(parser, is_train=True):16 assert not is_train, 'TestModel cannot be used in train mode'17 parser.set_defaults(dataset_mode='aligned')18 19 parser.add_argument('--model_suffix', type=str, default='',20 help='In checkpoints_dir, [which_epoch]_net_G[model_suffix].pth will'21 ' be loaded as the generator of TestModel')22 return parser23 24 def initialize(self, opt):25 assert(not opt.isTrain)26 BaseModel.initialize(self, opt)27 28 # specify the training losses you want to print out. The program will call base_model.get_current_losses29 self.loss_names = []30 # specify the images you want to save/display. The program will call base_model.get_current_visuals31 self.visual_names = ['fake_A','real_A']32 self.model_names = ['G']33 34 self.netG = networks.define_G('UNetDictFace',self.gpu_ids)35 36 def set_input(self, input):37 self.real_A = input['A'].to(self.device) #degraded img38 self.real_C = input['C'].to(self.device) #groundtruth39 self.image_paths = input['A_paths']40 self.Part_locations = input['Part_locations']41 42 def forward(self):43 44 self.fake_A = self.netG(self.real_A, self.Part_locations) #45 # try:46 # self.fake_A = self.netG(self.real_A, self.Part_locations) #生成图47 # except:48 # self.fake_A = self.real_A49 