manuelruder / artistic-videos

Torch implementation for the paper "Artistic style transfer for videos"
Other
1.75k stars 252 forks source link

Image.warp incorrect arguments #24

Closed Pantsworth closed 8 years ago

Pantsworth commented 8 years ago

Greetings,

Thanks for all your work on this project! I'm very excited to be getting it up and running.

Currently, I'm running into an error whilst trying to process images, and unfortunately I've been unable to find any help docs that pointed me to a fix.

Running Ubuntu 14.04, CUDA 7.5, latest pull of artistic-videos, all on AWS g2.2xlarge.

It looks like the inputs to the image.warp function are incorrect – not sure why this would be. A misconfigured lib someplace?

I generated this error with the following line:

th artistic_video.lua -content_pattern example/marple8_%02d.ppm -style_image example/seated-nude.jpg -num_images 0 -gpu 0

Output:

Reading flow file "example/deepflow/backward_2_1.flo". [res] image.warp([dst,]src,field,[mode,offset,clamp])

Warps image src (of size KxHxW ) according to flow field field . The latter has size 2xHxW where the first dimension is for the (y,x) flow field. String mode can take on values lanczos, bicubic, bilinear (the default), or simple. When offset is true (the default), (x,y) is added to the flow field. The clamp variable specifies how to handle the interpolation of samples off the input image. Permitted values are strings clamp (the default) or pad. If dst is specified, it is used to store the result of the warp.Otherwise, returns a new res Tensor. usage: image.warp( torch.Tensor -- input image (KxHxW) torch.Tensor -- (y,x) flow field (2xHxW) [string] -- mode: lanczos | bicubic | bilinear | simple [string] -- offset mode (add (x,y) to flow field) [string] -- clamp mode: how to handle interp of samples off the input image (clamp | pad) ) image.warp( torch.Tensor -- destination torch.Tensor -- input image (KxHxW) torch.Tensor -- (y,x) flow field (2xHxW) [string] -- mode: lanczos | bicubic | bilinear | simple [string] -- offset mode (add (x,y) to flow field) [string] -- clamp mode: how to handle interp of samples off the input image (clamp | pad) ) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

/home/ubuntu/torch-distro/install/bin/luajit: ...ubuntu/torch-distro/install/share/lua/5.1/dok/inline.lua:736: incorrect arguments stack traceback: [C]: in function 'error' ...ubuntu/torch-distro/install/share/lua/5.1/dok/inline.lua:736: in function 'error' ...ubuntu/torch-distro/install/share/lua/5.1/image/init.lua:807: in function 'warp' artistic_video.lua:293: in function 'warpImage' artistic_video.lua:182: in function 'main' artistic_video.lua:359: in main chunk [C]: in function 'dofile' ...rch-distro/install/lib/luarocks/rocks/trepl/scm-1/bin/th:131: in main chunk [C]: at 0x00406670

Any help is greatly appreciated.

EDIT: Success after editing line 293: Original: result = image.warp(img, flow, 'bilinear', true, 'pad', -1)

Changed: result = image.warp(img, flow, 'bilinear', true, 'clamp')

manuelruder commented 8 years ago

The image.warp function actually takes a seventh argument called 'pad_val': torch/image/doc/paramtransform.md

Maybe you are using an outdated torch installation?

Pantsworth commented 8 years ago

worked after updating Torch to latest version. Thanks!