Skip to content

Commit

Permalink
Fix bin2png to work with new torch
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbontar committed Aug 18, 2017
1 parent 712bcfb commit b944e2f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions samples/bin2png.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@ require 'image'

d = 70
h = 370
w = 1226
w= 1226

function fromfile(fname)
local size = io.open(fname):seek('end')
local x = torch.FloatTensor(torch.FloatStorage(fname, false, size / 4))
local nan_mask = x:ne(x)
x[nan_mask] = 1e38
return x
end

print('Writing left.png')
left = torch.FloatTensor(torch.FloatStorage('left.bin')):view(1, d, h, w):cuda()
left = fromfile('left.bin'):view(1, d, h, w)
_, left_ = left:min(2)
image.save('left.png', left_[1]:float():div(d))

print('Writing right.png')
right = torch.FloatTensor(torch.FloatStorage('right.bin')):view(1, d, h, w):cuda()
right = fromfile('right.bin'):view(1, d, h, w)
_, right_ = right:min(2)
image.save('right.png', right_[1]:float():div(d))

print('Writing disp.png')
disp = torch.FloatTensor(torch.FloatStorage('disp.bin')):view(1, 1, h, w)
disp = fromfile('disp.bin'):view(1, 1, h, w)
image.save('disp.png', disp[1]:div(d))

0 comments on commit b944e2f

Please sign in to comment.