summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/aligned_dataset.py22
-rw-r--r--options/base_options.py1
-rw-r--r--util/visualizer.py2
3 files changed, 12 insertions, 13 deletions
diff --git a/data/aligned_dataset.py b/data/aligned_dataset.py
index 8899cb2..f153f26 100644
--- a/data/aligned_dataset.py
+++ b/data/aligned_dataset.py
@@ -18,19 +18,17 @@ class AlignedDataset(BaseDataset):
def __getitem__(self, index):
AB_path = self.AB_paths[index]
AB = Image.open(AB_path).convert('RGB')
- AB = AB.resize((self.opt.loadSize * 2, self.opt.loadSize), Image.BICUBIC)
- AB = transforms.ToTensor()(AB)
+ w, h = AB.size
+ w2 = int(w / 2)
+ A = AB.crop((0, 0, w2, h)).resize((self.opt.loadSize, self.opt.loadSize), Image.BICUBIC)
+ B = AB.crop((w2, 0, w, h)).resize((self.opt.loadSize, self.opt.loadSize), Image.BICUBIC)
+ A = transforms.ToTensor()(A)
+ B = transforms.ToTensor()(B)
+ w_offset = random.randint(0, max(0, self.opt.loadSize - self.opt.fineSize - 1))
+ h_offset = random.randint(0, max(0, self.opt.loadSize - self.opt.fineSize - 1))
- w_total = AB.size(2)
- w = int(w_total / 2)
- h = AB.size(1)
- w_offset = random.randint(0, max(0, w - self.opt.fineSize - 1))
- h_offset = random.randint(0, max(0, h - self.opt.fineSize - 1))
-
- A = AB[:, h_offset:h_offset + self.opt.fineSize,
- w_offset:w_offset + self.opt.fineSize]
- B = AB[:, h_offset:h_offset + self.opt.fineSize,
- w + w_offset:w + w_offset + self.opt.fineSize]
+ A = A[:, h_offset:h_offset + self.opt.fineSize, w_offset:w_offset + self.opt.fineSize]
+ B = B[:, h_offset:h_offset + self.opt.fineSize, w_offset:w_offset + self.opt.fineSize]
A = transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))(A)
B = transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))(B)
diff --git a/options/base_options.py b/options/base_options.py
index ce58548..5bdd85e 100644
--- a/options/base_options.py
+++ b/options/base_options.py
@@ -33,6 +33,7 @@ class BaseOptions():
self.parser.add_argument('--serial_batches', action='store_true', help='if true, takes images in order to make batches, otherwise takes them randomly')
self.parser.add_argument('--display_winsize', type=int, default=256, help='display window size')
self.parser.add_argument('--display_id', type=int, default=1, help='window id of the web display')
+ self.parser.add_argument('--display_server', type=str, default="http://localhost", help='visdom server of the web display')
self.parser.add_argument('--display_port', type=int, default=8097, help='visdom port of the web display')
self.parser.add_argument('--no_dropout', action='store_true', help='no dropout for the generator')
self.parser.add_argument('--max_dataset_size', type=int, default=float("inf"),
diff --git a/util/visualizer.py b/util/visualizer.py
index fd8140d..a98b512 100644
--- a/util/visualizer.py
+++ b/util/visualizer.py
@@ -18,7 +18,7 @@ class Visualizer():
self.saved = False
if self.display_id > 0:
import visdom
- self.vis = visdom.Visdom(port=opt.display_port)
+ self.vis = visdom.Visdom(server=opt.display_server, port=opt.display_port)
if self.use_html:
self.web_dir = os.path.join(opt.checkpoints_dir, opt.name, 'web')