vlfeat / matconvnet-fcn

A MatConvNet-based implementation of the Fully-Convolutional Networks for image segmentation
Other
173 stars 125 forks source link

Test Image Segmentation #33

Open ectg opened 8 years ago

ectg commented 8 years ago

Hi,

I am trying to see the semantic segmentation results for a test image like peppers.png using the pretrained model, pascal-fcn16s-dag.mat. The quickstart guide at http://www.vlfeat.org/matconvnet/quick/ shows how to use DAG for classification, but not segmentation. How would I go about doing this?

Can someone help?

James1944 commented 7 years ago

Hi ectg, Were you able to complete this task and get the code running? Do you have any tips? I'm also struggling with getting this working.

Thank you James

zhangmozhe commented 7 years ago

Hi, have you solved this? I am new to matconvnet and just need the segmentation result...

Thanks! Bo

zisianw commented 7 years ago

@ectg @James1944 @zhangmozhe have you guys manages to figure out?

zhangmozhe commented 7 years ago

I found a solution but there's something needed to be changed for different versions of manconvnet. I put the codes below. Also, you can also train the net and modify the fcnTest.m in the matconvnet toolbox.

run matlab/vl_setupnn net = dagnn.DagNN.loadobj(load('pascal-fcn32s-dag.mat')) ; net.mode = 'test' ;

predVar = net.getVarIndex('upscore') ; inputVar = 'data' ; imageNeedsToBeMultiple = false ;
rgb = imread('./matconvnet/car.png') ; im_ = bsxfun(@minus, single(rgb), net.meta.normalization.averageImage) ;

net.evalr({inputVar, im}) ; scores = gather(net.vars(predVar).value) ; [~,pred] = max(scores,[],3) ; imshow(pred,[])

fanguu commented 7 years ago

@zhangmozhe I can't figure out the problem,why I use the code

net= dagnn.DagNN.loadobj(load('pascal-fcn32s-dag.mat')) ; there were following problems 错误使用 dagnn.Layer/load (line 191) No property dilate for a layer of type dagnn.Conv. 出错 dagnn.DagNN.loadobj (line 28) block.load(struct(s.layers(l).block)) ;

dancivitarese commented 7 years ago

Hi @zhangmozhe,

I had the same problem. That's because they didn't update the example after publishing beta23. You should replace your network_init example to a newer version where this parameter is properly given. Em sáb, 8 de out de 2016 às 22:48, fanguu notifications@github.com escreveu:

@zhangmozhe https://github.com/zhangmozhe I can't figure out the problem,why I use the code

net= dagnn.DagNN.loadobj(load('pascal-fcn32s-dag.mat')) ; there were following problems 错误使用 dagnn.Layer/load (line 191) No property dilate for a layer of type dagnn.Conv. 出错 dagnn.DagNN.loadobj (line 28) block.load(struct(s.layers(l).block)) ;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vlfeat/matconvnet-fcn/issues/33#issuecomment-252458834, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIcC491CqB0Ic4UM61EUgjy29DAspFoks5qyEf2gaJpZM4I0njs .

Daniel Salles Chevitarese

zisianw commented 7 years ago

@fanguu Try running the code in v1.0beta22, it worked for me. If you want to use it in v1.0beta23, try to follow @dchevitarese 's method.

mjohn123 commented 7 years ago

This is my script, it worked in beta 23. I hope it can help for someone who meet the issue above

net = dagnn.DagNN.loadobj(load('data/pascal-fcn32s-dag.mat')) ;
rgbPath='ILSVRC2012_test_00000036.jpeg';
rgb = vl_imreadjpeg({rgbPath}) ;
rgb = rgb{1} ;
% Subtract the mean (color)
im = bsxfun(@minus, single(rgb), net.meta.normalization.averageImage) ;
inputVar = 'data' ;
predVar = net.getVarIndex('upscore') ;
net.eval({inputVar, im}) ;
scores_ = gather(net.vars(predVar).value) ;
[~,pred_] = max(scores_,[],3) ;
displayImage(rgb/255, pred_);

The displayImage function is from fcnTest.m