Skip to content

Commit 4f74b38

Browse files
committed
Default Tensor type fix
1 parent c651e0a commit 4f74b38

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

init.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function M.configure(config)
6060
end
6161

6262
function M.image(img, opts)
63+
64+
local defaultType = torch.getdefaulttensortype()
65+
-- the image package expects this to be DoubleTensor
66+
-- if CudaTensor then clampImage from package image will attempt to index field 'image' (a nil value) of the CudaTensor
67+
torch.setdefaulttensortype('torch.DoubleTensor')
68+
6369
-- options:
6470
opts = opts or {}
6571

@@ -82,6 +88,7 @@ function M.image(img, opts)
8288
local inmem_img = image.compressJPG(img)
8389
local imgdata = 'data:image/jpg;base64,' .. mime.b64(ffi.string(inmem_img:data(), inmem_img:nElement()))
8490

91+
torch.setdefaulttensortype(defaultType)
8592

8693
return pane('image', opts.win, opts.title, { src=imgdata, labels=opts._labels, width=opts.width })
8794
end

0 commit comments

Comments
 (0)