Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Speed up top masks evaluation #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions InferDeepMask.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ function Infer:getTopMasks(thr,h,w)
local masks,topScores,np = self.mask,self.topScores,self.np
topMasks:resize(np,h,w):zero()
imgMask:resize(h,w)
local imgMaskPtr = imgMask:data()
imgMask:zero()

for i = 1,np do
imgMask:zero()
local imgMask_copy = imgMask:clone()
local imgMaskPtr = imgMask_copy:data()
local scale,x,y=topScores[i][2], topScores[i][3], topScores[i][4]
local s=self.scales[scale]
local sz = math.floor(self.iSz/s)
Expand All @@ -212,7 +213,7 @@ function Infer:getTopMasks(thr,h,w)
end
end
end
topMasks:narrow(1,i,1):copy(imgMask)
topMasks:narrow(1,i,1):copy(imgMask_copy)
end

return topMasks
Expand Down
7 changes: 4 additions & 3 deletions InferSharpMask.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ function Infer:getTopMasks(thr,h,w)
local topMasks0,topScores,np = self.topMasks0,self.topScores,self.np
topMasks:resize(np,h,w):zero()
imgMask:resize(h,w)
local imgMaskPtr = imgMask:data()
imgMask:zero()

for i = 1,np do
imgMask:zero()
local imgMask_copy = imgMask:clone()
local imgMaskPtr = imgMask_copy:data()
local scale,x,y = topScores[i][2],topScores[i][3],topScores[i][4]
local s = self.scales[scale]
local sz = math.floor(self.iSz/s)
Expand All @@ -306,7 +307,7 @@ function Infer:getTopMasks(thr,h,w)
end
end

topMasks:narrow(1,i,1):copy(imgMask)
topMasks:narrow(1,i,1):copy(imgMask_copy)
end

self.topMasks = topMasks
Expand Down