From 4f74b38ff9a01e1ed1678b8b5765c4a4f8634169 Mon Sep 17 00:00:00 2001 From: ilija Date: Tue, 27 Sep 2016 10:48:51 +0700 Subject: [PATCH] Default Tensor type fix --- init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init.lua b/init.lua index f29b66d..e0fbad1 100644 --- a/init.lua +++ b/init.lua @@ -60,6 +60,12 @@ function M.configure(config) end function M.image(img, opts) + + local defaultType = torch.getdefaulttensortype() + -- the image package expects this to be DoubleTensor + -- if CudaTensor then clampImage from package image will attempt to index field 'image' (a nil value) of the CudaTensor + torch.setdefaulttensortype('torch.DoubleTensor') + -- options: opts = opts or {} @@ -82,6 +88,7 @@ function M.image(img, opts) local inmem_img = image.compressJPG(img) local imgdata = 'data:image/jpg;base64,' .. mime.b64(ffi.string(inmem_img:data(), inmem_img:nElement())) + torch.setdefaulttensortype(defaultType) return pane('image', opts.win, opts.title, { src=imgdata, labels=opts._labels, width=opts.width }) end