Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segmentation fault when using gpu to resize, using opencv cudawar… #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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