From 86829ec696e543eb8cf181268e2be312fa572274 Mon Sep 17 00:00:00 2001 From: Koray Kavukcuoglu Date: Tue, 10 Apr 2012 21:49:44 -0400 Subject: [PATCH] corrected a bug when displaying non-double tensors --- display.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/display.lua b/display.lua index c703260..e834a8e 100644 --- a/display.lua +++ b/display.lua @@ -16,6 +16,11 @@ function fex.imToDisplay(x,params) for i=1,#x do xx[i]:copy(x[i]) end x=xx end + if x:type() == 'torch.DoubleTensor' then + x=x:clone() + else + x=x:double() + end if x:dim() == 2 then x=torch.Tensor(x):resize(1,x:size(1),x:size(2)) end @@ -66,7 +71,7 @@ function fex.imshow(im,params) require 'qttorch' params = params or {} local title = params.title or "Image Display" - local xx = fex.imToDisplay(im:clone(),params) + local xx = fex.imToDisplay(im,params) local wi,hi = xx:size(xx:dim()),xx:size(xx:dim()-1) local ww = params.win or qtwidget.newwindow(wi,hi,title) local xi = params.x or 0