summaryrefslogtreecommitdiff
path: root/models/one_direction_test_model.py
diff options
context:
space:
mode:
authorTaesung Park <taesung_park@berkeley.edu>2017-04-27 01:28:53 -0700
committerTaesung Park <taesung_park@berkeley.edu>2017-04-27 01:28:53 -0700
commite5b2fd6d36b4297c4314478e88820cd10943d192 (patch)
treeaa6bf853e47a858b3e9d8a5ed051377f9b0b6415 /models/one_direction_test_model.py
parentaf7420fc67f1a69349f8155bb85a3536314e377b (diff)
1. Added one_direction_test_model that generates the outputs in only one direction
2. Changed the option naming from ntrain to max_dataset_size
Diffstat (limited to 'models/one_direction_test_model.py')
-rw-r--r--models/one_direction_test_model.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/models/one_direction_test_model.py b/models/one_direction_test_model.py
new file mode 100644
index 0000000..37e1bbb
--- /dev/null
+++ b/models/one_direction_test_model.py
@@ -0,0 +1,51 @@
+from torch.autograd import Variable
+from collections import OrderedDict
+import util.util as util
+from .base_model import BaseModel
+from . import networks
+
+
+class OneDirectionTestModel(BaseModel):
+ def name(self):
+ return 'OneDirectionTestModel'
+
+ def initialize(self, opt):
+ BaseModel.initialize(self, opt)
+
+ nb = opt.batchSize
+ size = opt.fineSize
+ self.input_A = self.Tensor(nb, opt.input_nc, size, size)
+
+ assert(not self.isTrain)
+ self.netG_A = networks.define_G(opt.input_nc, opt.output_nc,
+ opt.ngf, opt.which_model_netG,
+ opt.norm, opt.use_dropout,
+ self.gpu_ids)
+ which_epoch = opt.which_epoch
+ AtoB = self.opt.which_direction == 'AtoB'
+ which_network = 'G_A' if AtoB else 'G_B'
+ self.load_network(self.netG_A, which_network, which_epoch)
+
+ print('---------- Networks initialized -------------')
+ networks.print_network(self.netG_A)
+ print('-----------------------------------------------')
+
+ def set_input(self, input):
+ AtoB = self.opt.which_direction == 'AtoB'
+ input_A = input['A' if AtoB else 'B']
+ self.input_A.resize_(input_A.size()).copy_(input_A)
+ self.image_paths = input['A_paths' if AtoB else 'B_paths']
+
+ def test(self):
+ self.real_A = Variable(self.input_A)
+ self.fake_B = self.netG_A.forward(self.real_A)
+
+ #get image paths
+ def get_image_paths(self):
+ return self.image_paths
+
+ def get_current_visuals(self):
+ real_A = util.tensor2im(self.real_A.data)
+ fake_B = util.tensor2im(self.fake_B.data)
+ return OrderedDict([('real_A', real_A), ('fake_B', fake_B)])
+