From 3e654b9e1c52e66df8aef7faf354106814611551 Mon Sep 17 00:00:00 2001 From: Brannon Dorsey Date: Tue, 29 Nov 2016 17:07:05 -0600 Subject: [PATCH 01/16] In the process of adding loss plotting to train.lua --- train.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) mode change 100755 => 100644 train.lua diff --git a/train.lua b/train.lua old mode 100755 new mode 100644 index f1e1bc06..d2950fa5 --- a/train.lua +++ b/train.lua @@ -314,6 +314,16 @@ file = torch.DiskFile(paths.concat(opt.checkpoints_dir, opt.name, 'opt.txt'), 'w file:writeObject(opt) file:close() +-- display plot config +local plot_config = { + title = "Loss over time", + labels = {"epoch", "errG", "errD", "errL1"}, + ylabel = "loss", +} +-- display plot vars +local plot_data = {} +local plot_win + local counter = 0 for epoch = 1, opt.niter do epoch_tm:reset() @@ -328,7 +338,7 @@ for epoch = 1, opt.niter do -- (2) Update G network: maximize log(D(x,G(x))) + L1(y,G(x)) optim.adam(fGx, parametersG, optimStateG) - + -- display counter = counter + 1 if counter % opt.display_freq == 0 and opt.display then @@ -385,6 +395,10 @@ for epoch = 1, opt.niter do math.floor(math.min(data:size(), opt.ntrain) / opt.batchSize), tm:time().real / opt.batchSize, data_tm:time().real / opt.batchSize, errG and errG or -1, errD and errD or -1, errL1 and errL1 or -1)) + -- update display plot + table.insert(plot_data, {epoch, errG, errD, errL1}) + plot_config.win = plot_win + plot_win = disp.plot(plot_data, plot_config) end -- save latest model From 7ffe851b7885b24cfdcb3f43ff2b924abc293d96 Mon Sep 17 00:00:00 2001 From: Brannon Dorsey Date: Wed, 30 Nov 2016 15:47:22 -0600 Subject: [PATCH 02/16] Add display_plot env variable support in train.lua. errL1, errG, and errD can now be plotted to the display UI during training. --- README.md | 2 ++ train.lua | 32 ++++++++++++++++++++++++++------ util/util.lua | 7 +++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ca08f625..885f8c18 100755 --- a/README.md +++ b/README.md @@ -111,6 +111,8 @@ th -ldisplay.start 8000 0.0.0.0 ``` Then open `http://(hostname):(port)/` in your browser to load the remote desktop. +L1 error is plotted to the display by default. Set the environment variable `display_plot` to a comma-seperated list of values `errL1`, `errG` and `errD` to visualize the L1, generator, and descriminator error respectively. For example, to plot only the generator and descriminator errors to the display instead of the default L1 error, set `display_plot="errG,errD"`. + ## Citation If you use this code for your research, please cite our paper Image-to-Image Translation Using Conditional Adversarial Networks: diff --git a/train.lua b/train.lua index d2950fa5..1139a3aa 100644 --- a/train.lua +++ b/train.lua @@ -27,6 +27,7 @@ opt = { flip = 1, -- if flip the images for data argumentation display = 1, -- display samples while training. 0 = false display_id = 10, -- display window id. + display_plot = 'errL1', -- which loss values to plot over time. Accepted values include a comma seperated list of: errL1, errG, and errD gpu = 1, -- gpu = 0 is CPU mode. gpu=X is GPU mode on GPU X name = '', -- name of the experiment, should generally be passed on the command line which_direction = 'AtoB', -- AtoB or BtoA @@ -314,12 +315,21 @@ file = torch.DiskFile(paths.concat(opt.checkpoints_dir, opt.name, 'opt.txt'), 'w file:writeObject(opt) file:close() +-- parse diplay_plot string into table +opt.display_plot = string.split(string.gsub(opt.display_plot, "%s+", ""), ",") +for k, v in ipairs(opt.display_plot) do + if not util.containsValue({"errG", "errD", "errL1"}, v) then + error(string.format('bad display_plot value "%s"', v)) + end +end + -- display plot config local plot_config = { title = "Loss over time", - labels = {"epoch", "errG", "errD", "errL1"}, + labels = {"epoch", unpack(opt.display_plot)}, ylabel = "loss", } + -- display plot vars local plot_data = {} local plot_win @@ -387,16 +397,26 @@ for epoch = 1, opt.niter do opt.serial_batches=serial_batches end - -- logging + -- logging and display plot if counter % opt.print_freq == 0 then + local loss = {errG=errG and errG or -1, errD=errD and errD or -1, errL1=errL1 and errL1 or -1} + local curItInBatch = ((i-1) / opt.batchSize) + local totalItInBatch = math.floor(math.min(data:size(), opt.ntrain) / opt.batchSize) print(('Epoch: [%d][%8d / %8d]\t Time: %.3f DataTime: %.3f ' .. ' Err_G: %.4f Err_D: %.4f ErrL1: %.4f'):format( - epoch, ((i-1) / opt.batchSize), - math.floor(math.min(data:size(), opt.ntrain) / opt.batchSize), + epoch, curItInBatch, totalItInBatch, tm:time().real / opt.batchSize, data_tm:time().real / opt.batchSize, - errG and errG or -1, errD and errD or -1, errL1 and errL1 or -1)) + errG, errD, errL1)) + + local plot_vals = { epoch + curItInBatch / totalItInBatch } + for k, v in ipairs(opt.display_plot) do + if loss[v] ~= nil then + plot_vals[#plot_vals + 1] = loss[v] + end + end + -- update display plot - table.insert(plot_data, {epoch, errG, errD, errL1}) + table.insert(plot_data, plot_vals) plot_config.win = plot_win plot_win = disp.plot(plot_data, plot_config) end diff --git a/util/util.lua b/util/util.lua index 3042ef5a..78acd4b1 100755 --- a/util/util.lua +++ b/util/util.lua @@ -219,4 +219,11 @@ function util.cudnn(net) return cudnn_convert_custom(net, cudnn) end +function util.containsValue(table, value) + for k, v in pairs(table) do + if v == value then return true end + end + return false +end + return util From 1f4def86ec774d35933f04aa14d4ca52e9c3824c Mon Sep 17 00:00:00 2001 From: Brannon Dorsey Date: Wed, 30 Nov 2016 15:53:54 -0600 Subject: [PATCH 03/16] Add conditional check to make sure that display env is set before plotting errors. --- train.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/train.lua b/train.lua index 1139a3aa..f87be2b3 100644 --- a/train.lua +++ b/train.lua @@ -416,9 +416,11 @@ for epoch = 1, opt.niter do end -- update display plot - table.insert(plot_data, plot_vals) - plot_config.win = plot_win - plot_win = disp.plot(plot_data, plot_config) + if opt.display then + table.insert(plot_data, plot_vals) + plot_config.win = plot_win + plot_win = disp.plot(plot_data, plot_config) + end end -- save latest model From a96cc9bd402e10f0a77fb2f14066cb3454ce5f39 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 03:58:58 +0300 Subject: [PATCH 04/16] Updated combine script: change to cv2.IMREAD_COLOR Additional description may be found here: http://stackoverflow.com/questions/19013961/cv2-imread-flags-not-found This change allows easier setup on Amazon Deep Learning AMI. --- data/combine_A_and_B.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/combine_A_and_B.py b/data/combine_A_and_B.py index 035830be..c9d5e4ca 100755 --- a/data/combine_A_and_B.py +++ b/data/combine_A_and_B.py @@ -43,8 +43,8 @@ if args.use_AB: name_AB = name_AB.replace('_A.', '.') # remove _A path_AB = os.path.join(img_fold_AB, name_AB) - im_A = cv2.imread(path_A, cv2.CV_LOAD_IMAGE_COLOR) - im_B = cv2.imread(path_B, cv2.CV_LOAD_IMAGE_COLOR) + im_A = cv2.imread(path_A, cv2.IMREAD_COLOR) + im_B = cv2.imread(path_B, cv2.IMREAD_COLOR) im_AB = np.concatenate([im_A, im_B], 1) cv2.imwrite(path_AB, im_AB) From 1abe78b2ce37c05feebb4089c37abefd2d5cf4f7 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 04:30:23 +0300 Subject: [PATCH 05/16] udpate image sizes in train.lua --- train.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/train.lua b/train.lua index f87be2b3..1f427eab 100644 --- a/train.lua +++ b/train.lua @@ -15,7 +15,8 @@ opt = { DATA_ROOT = '', -- path to images (should have subfolders 'train', 'val', etc) batchSize = 1, -- # images in batch loadSize = 286, -- scale images to this size - fineSize = 256, -- then crop to this size + imgWidth = 720, -- then crop to this size + imgHeight = 1280, ngf = 64, -- # of gen filters in first conv layer ndf = 64, -- # of discrim filters in first conv layer input_nc = 3, -- # of input image channels @@ -166,11 +167,11 @@ optimStateD = { beta1 = opt.beta1, } ---------------------------------------------------------------------------- -local real_A = torch.Tensor(opt.batchSize, input_nc, opt.fineSize, opt.fineSize) -local real_B = torch.Tensor(opt.batchSize, output_nc, opt.fineSize, opt.fineSize) -local fake_B = torch.Tensor(opt.batchSize, output_nc, opt.fineSize, opt.fineSize) -local real_AB = torch.Tensor(opt.batchSize, output_nc + input_nc*opt.condition_GAN, opt.fineSize, opt.fineSize) -local fake_AB = torch.Tensor(opt.batchSize, output_nc + input_nc*opt.condition_GAN, opt.fineSize, opt.fineSize) +local real_A = torch.Tensor(opt.batchSize, input_nc, opt.imgWidth, opt.imgHeight) +local real_B = torch.Tensor(opt.batchSize, output_nc, opt.imgWidth, opt.imgHeight) +local fake_B = torch.Tensor(opt.batchSize, output_nc, opt.imgWidth, opt.imgHeight) +local real_AB = torch.Tensor(opt.batchSize, output_nc + input_nc*opt.condition_GAN, opt.imgWidth, opt.imgHeight) +local fake_AB = torch.Tensor(opt.batchSize, output_nc + input_nc*opt.condition_GAN, opt.imgWidth, opt.imgHeight) local errD, errG, errL1 = 0, 0, 0 local epoch_tm = torch.Timer() local tm = torch.Timer() @@ -445,4 +446,4 @@ for epoch = 1, opt.niter do epoch, opt.niter, epoch_tm:time().real)) parametersD, gradParametersD = netD:getParameters() -- reflatten the params and get them parametersG, gradParametersG = netG:getParameters() -end \ No newline at end of file +end From 4b7c14a7485db24f5edbd38728d453fefa6c1b1e Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 04:32:20 +0300 Subject: [PATCH 06/16] Update image sizes in test.lua --- test.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test.lua b/test.lua index 60676b73..a7827541 100755 --- a/test.lua +++ b/test.lua @@ -13,7 +13,8 @@ opt = { DATA_ROOT = '', -- path to images (should have subfolders 'train', 'val', etc) batchSize = 1, -- # images in batch loadSize = 256, -- scale images to this size - fineSize = 256, -- then crop to this size + imgWidth = 720, -- then crop to this size + imgHeight = 1280, flip=0, -- horizontal mirroring data augmentation display = 1, -- display samples while training. 0 = false display_id = 200, -- display window id. @@ -69,8 +70,8 @@ else end ---------------------------------------------------------------------------- -local input = torch.FloatTensor(opt.batchSize,3,opt.fineSize,opt.fineSize) -local target = torch.FloatTensor(opt.batchSize,3,opt.fineSize,opt.fineSize) +local input = torch.FloatTensor(opt.batchSize,3,opt.imgWidth,opt.imgHeight) +local target = torch.FloatTensor(opt.batchSize,3,opt.imgWidth,opt.imgHeight) print('checkpoints_dir', opt.checkpoints_dir) local netG = util.load(paths.concat(opt.checkpoints_dir, opt.netG_name .. '.t7'), opt) @@ -164,4 +165,4 @@ for i=1, #filepaths do io.write('') end -io.write('') \ No newline at end of file +io.write('') From 800808b5df21765fc51ee9acfdf6df153ac6a755 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 04:45:03 +0300 Subject: [PATCH 07/16] update loader for image size --- data/donkey_folder.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/data/donkey_folder.lua b/data/donkey_folder.lua index 9f53dc01..bc6a81ea 100755 --- a/data/donkey_folder.lua +++ b/data/donkey_folder.lua @@ -33,12 +33,12 @@ local trainCache = paths.concat(cache, cache_prefix .. '_trainCache.t7') -------------------------------------------------------------------------------------------- local input_nc = opt.input_nc -- input channels local output_nc = opt.output_nc -local loadSize = {input_nc, opt.loadSize} -local sampleSize = {input_nc, opt.fineSize} +local loadSize = {input_nc, opt.imgWidth, opt.imgHeight} +local sampleSize = {input_nc, opt.imgWidth, opt.imgHeight} local preprocessAandB = function(imA, imB) - imA = image.scale(imA, loadSize[2], loadSize[2]) - imB = image.scale(imB, loadSize[2], loadSize[2]) + imA = image.scale(imA, loadSize[2], loadSize[3]) + imB = image.scale(imB, loadSize[2], loadSize[3]) local perm = torch.LongTensor{3, 2, 1} imA = imA:index(1, perm)--:mul(256.0): brg, rgb imA = imA:mul(2):add(-1) @@ -52,7 +52,7 @@ local preprocessAandB = function(imA, imB) local oW = sampleSize[2] - local oH = sampleSize[2] + local oH = sampleSize[3] local iH = imA:size(2) local iW = imA:size(3) @@ -80,10 +80,10 @@ end local function loadImageChannel(path) local input = image.load(path, 3, 'float') - input = image.scale(input, loadSize[2], loadSize[2]) + input = image.scale(input, loadSize[2], loadSize[3]) local oW = sampleSize[2] - local oH = sampleSize[2] + local oH = sampleSize[3] local iH = input:size(2) local iW = input:size(3) @@ -161,7 +161,7 @@ print('trainCache', trainCache) -- trainLoader = torch.load(trainCache) -- trainLoader.sampleHookTrain = trainHook -- trainLoader.loadSize = {input_nc, opt.loadSize, opt.loadSize} --- trainLoader.sampleSize = {input_nc+output_nc, sampleSize[2], sampleSize[2]} +-- trainLoader.sampleSize = {input_nc+output_nc, sampleSize[2], sampleSize[3]} -- trainLoader.serial_batches = opt.serial_batches -- trainLoader.split = 100 --else @@ -170,8 +170,8 @@ print('Creating train metadata') print('serial batch:, ', opt.serial_batches) trainLoader = dataLoader{ paths = {opt.data}, - loadSize = {input_nc, loadSize[2], loadSize[2]}, - sampleSize = {input_nc+output_nc, sampleSize[2], sampleSize[2]}, + loadSize = {input_nc, loadSize[2], loadSize[3]}, + sampleSize = {input_nc+output_nc, sampleSize[2], sampleSize[3]}, split = 100, serial_batches = opt.serial_batches, verbose = true @@ -189,4 +189,4 @@ do local nClasses = #trainLoader.classes assert(class:max() <= nClasses, "class logic has error") assert(class:min() >= 1, "class logic has error") -end \ No newline at end of file +end From 42dc2b58f2b326bdb3f4bf6617ef225b6c950b6a Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 01:54:45 +0000 Subject: [PATCH 08/16] Update more to have needed size --- test.lua | 2 +- train.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test.lua b/test.lua index a7827541..9968f051 100755 --- a/test.lua +++ b/test.lua @@ -13,7 +13,7 @@ opt = { DATA_ROOT = '', -- path to images (should have subfolders 'train', 'val', etc) batchSize = 1, -- # images in batch loadSize = 256, -- scale images to this size - imgWidth = 720, -- then crop to this size + imgWidth = 736, -- then crop to this size. Both should be multiples of 32... imgHeight = 1280, flip=0, -- horizontal mirroring data augmentation display = 1, -- display samples while training. 0 = false diff --git a/train.lua b/train.lua index 1f427eab..2705b0cc 100644 --- a/train.lua +++ b/train.lua @@ -15,7 +15,7 @@ opt = { DATA_ROOT = '', -- path to images (should have subfolders 'train', 'val', etc) batchSize = 1, -- # images in batch loadSize = 286, -- scale images to this size - imgWidth = 720, -- then crop to this size + imgWidth = 736, -- then crop to this size. Both should be multiples of 32... imgHeight = 1280, ngf = 64, -- # of gen filters in first conv layer ndf = 64, -- # of discrim filters in first conv layer From a4bf764a9e53eb24d53b7dca143f82a07b334507 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 02:34:55 +0000 Subject: [PATCH 09/16] Size... --- test.lua | 4 ++-- train.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test.lua b/test.lua index 9968f051..6a31c1a0 100755 --- a/test.lua +++ b/test.lua @@ -13,8 +13,8 @@ opt = { DATA_ROOT = '', -- path to images (should have subfolders 'train', 'val', etc) batchSize = 1, -- # images in batch loadSize = 256, -- scale images to this size - imgWidth = 736, -- then crop to this size. Both should be multiples of 32... - imgHeight = 1280, + imgWidth = 256, -- then crop to this size. Both should be multiples of 32... + imgHeight = 512, flip=0, -- horizontal mirroring data augmentation display = 1, -- display samples while training. 0 = false display_id = 200, -- display window id. diff --git a/train.lua b/train.lua index 2705b0cc..1d89e763 100644 --- a/train.lua +++ b/train.lua @@ -15,8 +15,8 @@ opt = { DATA_ROOT = '', -- path to images (should have subfolders 'train', 'val', etc) batchSize = 1, -- # images in batch loadSize = 286, -- scale images to this size - imgWidth = 736, -- then crop to this size. Both should be multiples of 32... - imgHeight = 1280, + imgWidth = 256, -- then crop to this size. Both should be multiples of 32... + imgHeight = 512, ngf = 64, -- # of gen filters in first conv layer ndf = 64, -- # of discrim filters in first conv layer input_nc = 3, -- # of input image channels From 9e9722681987167504edfb96a9c4c689949db342 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 05:45:24 +0300 Subject: [PATCH 10/16] Sizes... --- train.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/train.lua b/train.lua index 1d89e763..5382c721 100644 --- a/train.lua +++ b/train.lua @@ -38,7 +38,7 @@ opt = { save_epoch_freq = 50, -- save a model every save_epoch_freq epochs (does not overwrite previously saved models) save_latest_freq = 5000, -- save the latest model every latest_freq sgd iterations (overwrites the previous latest model) print_freq = 50, -- print the debug information every print_freq iterations - display_freq = 100, -- display the current results every display_freq iterations + display_freq = 20, -- display the current results every display_freq iterations save_display_freq = 5000, -- save the current display of results every save_display_freq_iterations continue_train=0, -- if continue training, load the latest model: 1: true, 0: false serial_batches = 0, -- if 1, takes images in order to make batches, otherwise takes them randomly @@ -355,16 +355,16 @@ for epoch = 1, opt.niter do if counter % opt.display_freq == 0 and opt.display then createRealFake() if opt.preprocess == 'colorization' then - local real_A_s = util.scaleBatch(real_A:float(),100,100) - local fake_B_s = util.scaleBatch(fake_B:float(),100,100) - local real_B_s = util.scaleBatch(real_B:float(),100,100) + local real_A_s = util.scaleBatch(real_A:float(),256,512) + local fake_B_s = util.scaleBatch(fake_B:float(),256,512) + local real_B_s = util.scaleBatch(real_B:float(),256,512) disp.image(util.deprocessL_batch(real_A_s), {win=opt.display_id, title=opt.name .. ' input'}) disp.image(util.deprocessLAB_batch(real_A_s, fake_B_s), {win=opt.display_id+1, title=opt.name .. ' output'}) disp.image(util.deprocessLAB_batch(real_A_s, real_B_s), {win=opt.display_id+2, title=opt.name .. ' target'}) else - disp.image(util.deprocess_batch(util.scaleBatch(real_A:float(),100,100)), {win=opt.display_id, title=opt.name .. ' input'}) - disp.image(util.deprocess_batch(util.scaleBatch(fake_B:float(),100,100)), {win=opt.display_id+1, title=opt.name .. ' output'}) - disp.image(util.deprocess_batch(util.scaleBatch(real_B:float(),100,100)), {win=opt.display_id+2, title=opt.name .. ' target'}) + disp.image(util.deprocess_batch(util.scaleBatch(real_A:float(),256,512)), {win=opt.display_id, title=opt.name .. ' input'}) + disp.image(util.deprocess_batch(util.scaleBatch(fake_B:float(),256,512)), {win=opt.display_id+1, title=opt.name .. ' output'}) + disp.image(util.deprocess_batch(util.scaleBatch(real_B:float(),256,512)), {win=opt.display_id+2, title=opt.name .. ' target'}) end end From 79cc823587e5d18c08881121076184183732b770 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 05:47:20 +0300 Subject: [PATCH 11/16] Update train.lua --- train.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/train.lua b/train.lua index 5382c721..5d8133d0 100644 --- a/train.lua +++ b/train.lua @@ -355,16 +355,16 @@ for epoch = 1, opt.niter do if counter % opt.display_freq == 0 and opt.display then createRealFake() if opt.preprocess == 'colorization' then - local real_A_s = util.scaleBatch(real_A:float(),256,512) - local fake_B_s = util.scaleBatch(fake_B:float(),256,512) - local real_B_s = util.scaleBatch(real_B:float(),256,512) + local real_A_s = util.scaleBatch(real_A:float(),512,256) + local fake_B_s = util.scaleBatch(fake_B:float(),512,256) + local real_B_s = util.scaleBatch(real_B:float(),512,256) disp.image(util.deprocessL_batch(real_A_s), {win=opt.display_id, title=opt.name .. ' input'}) disp.image(util.deprocessLAB_batch(real_A_s, fake_B_s), {win=opt.display_id+1, title=opt.name .. ' output'}) disp.image(util.deprocessLAB_batch(real_A_s, real_B_s), {win=opt.display_id+2, title=opt.name .. ' target'}) else - disp.image(util.deprocess_batch(util.scaleBatch(real_A:float(),256,512)), {win=opt.display_id, title=opt.name .. ' input'}) - disp.image(util.deprocess_batch(util.scaleBatch(fake_B:float(),256,512)), {win=opt.display_id+1, title=opt.name .. ' output'}) - disp.image(util.deprocess_batch(util.scaleBatch(real_B:float(),256,512)), {win=opt.display_id+2, title=opt.name .. ' target'}) + disp.image(util.deprocess_batch(util.scaleBatch(real_A:float(),512,256)), {win=opt.display_id, title=opt.name .. ' input'}) + disp.image(util.deprocess_batch(util.scaleBatch(fake_B:float(),512,256)), {win=opt.display_id+1, title=opt.name .. ' output'}) + disp.image(util.deprocess_batch(util.scaleBatch(real_B:float(),512,256)), {win=opt.display_id+2, title=opt.name .. ' target'}) end end From 9db2f00621a39615352a6d58d836daaf2b380c18 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 13:26:06 +0300 Subject: [PATCH 12/16] Update test.lua --- test.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.lua b/test.lua index 6a31c1a0..a63a2e42 100755 --- a/test.lua +++ b/test.lua @@ -139,9 +139,9 @@ for n=1,math.floor(opt.how_many/opt.batchSize) do if opt.display then if opt.preprocess == 'regular' then disp = require 'display' - disp.image(util.scaleBatch(input,100,100),{win=opt.display_id, title='input'}) - disp.image(util.scaleBatch(output,100,100),{win=opt.display_id+1, title='output'}) - disp.image(util.scaleBatch(target,100,100),{win=opt.display_id+2, title='target'}) + disp.image(util.scaleBatch(input,512,256),{win=opt.display_id, title='input'}) + disp.image(util.scaleBatch(output,512,256),{win=opt.display_id+1, title='output'}) + disp.image(util.scaleBatch(target,512,256),{win=opt.display_id+2, title='target'}) print('Displayed images') end From 1cd858d970e8a9c8a5929b3efb64b7b783d4d341 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 13:30:58 +0300 Subject: [PATCH 13/16] Update test.lua --- test.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.lua b/test.lua index a63a2e42..37fbbd67 100755 --- a/test.lua +++ b/test.lua @@ -130,9 +130,9 @@ for n=1,math.floor(opt.how_many/opt.batchSize) do print(output:size()) print(target:size()) for i=1, opt.batchSize do - image.save(paths.concat(image_dir,'input',filepaths_curr[i]), image.scale(input[i],input[i]:size(2),input[i]:size(3)/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'output',filepaths_curr[i]), image.scale(output[i],output[i]:size(2),output[i]:size(3)/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'target',filepaths_curr[i]), image.scale(target[i],target[i]:size(2),target[i]:size(3)/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'input',filepaths_curr[i]), image.scale(input[i],input[i]:size(2),input[i]:size(3))) --/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'output',filepaths_curr[i]), image.scale(output[i],output[i]:size(2),output[i]:size(3)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'target',filepaths_curr[i]), image.scale(target[i],target[i]:size(2),target[i]:size(3)))--/opt.aspect_ratio)) end print('Saved images to: ', image_dir) From 6c706825012ca7661481974a16e638bee3568485 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 13:35:28 +0300 Subject: [PATCH 14/16] Update test.lua --- test.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.lua b/test.lua index 37fbbd67..221c796e 100755 --- a/test.lua +++ b/test.lua @@ -130,9 +130,9 @@ for n=1,math.floor(opt.how_many/opt.batchSize) do print(output:size()) print(target:size()) for i=1, opt.batchSize do - image.save(paths.concat(image_dir,'input',filepaths_curr[i]), image.scale(input[i],input[i]:size(2),input[i]:size(3))) --/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'output',filepaths_curr[i]), image.scale(output[i],output[i]:size(2),output[i]:size(3)))--/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'target',filepaths_curr[i]), image.scale(target[i],target[i]:size(2),target[i]:size(3)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'input',filepaths_curr[i]), image.scale(input[i],input[i]:size(3),input[i]:size(2))) --/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'output',filepaths_curr[i]), image.scale(output[i],output[i]:size(3),output[i]:size(2)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'target',filepaths_curr[i]), image.scale(target[i],target[i]:size(3),target[i]:size(2)))--/opt.aspect_ratio)) end print('Saved images to: ', image_dir) From 76812d9fbd47a0f1c641e0dc9f4044a136918540 Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 13:45:55 +0300 Subject: [PATCH 15/16] Update test.lua --- test.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test.lua b/test.lua index 221c796e..5444a0cc 100755 --- a/test.lua +++ b/test.lua @@ -70,8 +70,8 @@ else end ---------------------------------------------------------------------------- -local input = torch.FloatTensor(opt.batchSize,3,opt.imgWidth,opt.imgHeight) -local target = torch.FloatTensor(opt.batchSize,3,opt.imgWidth,opt.imgHeight) +local input = torch.FloatTensor(opt.batchSize,3,opt.imgHeight,opt.imgWidth) +local target = torch.FloatTensor(opt.batchSize,3,opt.imgHeight,opt.imgWidth) print('checkpoints_dir', opt.checkpoints_dir) local netG = util.load(paths.concat(opt.checkpoints_dir, opt.netG_name .. '.t7'), opt) @@ -130,9 +130,9 @@ for n=1,math.floor(opt.how_many/opt.batchSize) do print(output:size()) print(target:size()) for i=1, opt.batchSize do - image.save(paths.concat(image_dir,'input',filepaths_curr[i]), image.scale(input[i],input[i]:size(3),input[i]:size(2))) --/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'output',filepaths_curr[i]), image.scale(output[i],output[i]:size(3),output[i]:size(2)))--/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'target',filepaths_curr[i]), image.scale(target[i],target[i]:size(3),target[i]:size(2)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'input',filepaths_curr[i]), input[i]))--image.scale(input[i],input[i]:size(3),input[i]:size(2))) --/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'output',filepaths_curr[i]), output[i]))--image.scale(output[i],output[i]:size(3),output[i]:size(2)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'target',filepaths_curr[i]), target[i]))--image.scale(target[i],target[i]:size(3),target[i]:size(2)))--/opt.aspect_ratio)) end print('Saved images to: ', image_dir) From 95a7aa437f66cf5f53a75fedb7ae09df6ed4455f Mon Sep 17 00:00:00 2001 From: Rustem Mustafin Date: Tue, 6 Dec 2016 13:47:11 +0300 Subject: [PATCH 16/16] Update test.lua --- test.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.lua b/test.lua index 5444a0cc..45176dcc 100755 --- a/test.lua +++ b/test.lua @@ -130,9 +130,9 @@ for n=1,math.floor(opt.how_many/opt.batchSize) do print(output:size()) print(target:size()) for i=1, opt.batchSize do - image.save(paths.concat(image_dir,'input',filepaths_curr[i]), input[i]))--image.scale(input[i],input[i]:size(3),input[i]:size(2))) --/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'output',filepaths_curr[i]), output[i]))--image.scale(output[i],output[i]:size(3),output[i]:size(2)))--/opt.aspect_ratio)) - image.save(paths.concat(image_dir,'target',filepaths_curr[i]), target[i]))--image.scale(target[i],target[i]:size(3),target[i]:size(2)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'input',filepaths_curr[i]), input[i])--image.scale(input[i],input[i]:size(3),input[i]:size(2))) --/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'output',filepaths_curr[i]), output[i])--image.scale(output[i],output[i]:size(3),output[i]:size(2)))--/opt.aspect_ratio)) + image.save(paths.concat(image_dir,'target',filepaths_curr[i]), target[i])--image.scale(target[i],target[i]:size(3),target[i]:size(2)))--/opt.aspect_ratio)) end print('Saved images to: ', image_dir)