Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion videocaptioning.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ torch.setdefaulttensortype('torch.FloatTensor') -- for CPU
if opt.gpuid >= 0 then
require 'cutorch'
require 'cunn'
require 'cv.cudawarping'
if opt.backend == 'cudnn' then require 'cudnn' end
cutorch.manualSeed(opt.seed)
cutorch.setDevice(opt.gpuid + 1) -- note +1 because lua is 1-indexed
Expand Down Expand Up @@ -102,7 +103,12 @@ local function run()

-- take a central crop
local crop = cv.getRectSubPix{image=frame, patchSize={h,h}, center={w/2, h/2}}
local cropsc = cv.resize{src=crop, dsize={256,256}}
local cropsc
if opt.gpuid >= 0 then
cropsc = cv.cuda.resize{src=crop:cuda(), dsize={256,256}}
else
cropsc = cv.resize{src=crop, dsize={256,256}}
end
-- BGR2RGB
cropsc = cropsc:index(3,torch.LongTensor{3,2,1})
-- HWC2CHW
Expand Down