Skip to content

Commit

Permalink
fix display_id bug
Browse files Browse the repository at this point in the history
  • Loading branch information
junyanz committed Apr 8, 2017
1 parent 6e84367 commit 749c985
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ else
print ("CPU Mode")
end

-- visualizer
-- setup visualization
visualizer = require 'util/visualizer'
print(visualizer.save_images)

function TableConcat(t1,t2)
for i=1,#t2 do
Expand Down
5 changes: 1 addition & 4 deletions train.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ options = require 'options'
opt = options.parse_options('train')

-- setup visualization
if opt.display_id > 0 then
disp = require 'display'
visualizer = require 'util/visualizer'
end
visualizer = require 'util/visualizer'

-- initialize torch GPU/CPU mode
if opt.gpu > 0 then
Expand Down
7 changes: 6 additions & 1 deletion util/visualizer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
local visualizer = {}

require 'torch'
disp = require 'display'
disp = nil

if opt.display_id > 0 then -- [hack]: assume that opt already existed
disp = require 'display'
end
util = require 'util/util'
require 'image'

-- function visualizer
function visualizer.disp_image(img_data, win_size, display_id, title)
local tensortype = torch.getdefaulttensortype()
disp.image(util.deprocess_batch(util.scaleBatch(img_data:float(),win_size,win_size)), {win=display_id, title=title})
Expand Down

0 comments on commit 749c985

Please sign in to comment.