Last active
August 29, 2015 14:21
-
-
Save culurciello/20c4acfc05e54dde1244 to your computer and use it in GitHub Desktop.
pseudo-object segmentations on output of convnet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local mask = function (inputImage, mask, th) | |
local temp | |
mask = mask[1] | |
k = image.gaussian{size = 7, normalize = true}:float() | |
mask = image.convolve(mask, k, 'same'):repeatTensor(3,1,1) | |
temp = mask:gt(th):float():mul(.8):add(.2) | |
return inputImage:clone():cmul(temp) | |
end | |
local gradManipulation = function (grad, th) | |
return grad:float():abs():max(1):repeatTensor(3,1,1) | |
end | |
display.forward = function(output, fps) | |
win:gbegin() | |
win:showpage() | |
-- compute heatmap for category person! | |
local target = output[1]:clone():zero() -- only pick largest scale! | |
target[2] = (output[1])[2]:clone():mul(-1) -- only pick largest scale! | |
local gradInput = network.model:updateGradInput(source.scaled, target) | |
heat = mask(source.frame, gradManipulation(image.scale(gradInput, source.frame:size(3), source.frame:size(2)), 0), .2) | |
image.display{image = heat, win = win} | |
-- end displaying! | |
win:gend() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function creates a pseudo-proto-object segmentation from CNN output
output is output of CNN