Is there any example about fcnLayers and its predictions for semantic segmentation

조회 수: 2 (최근 30일)
Even though the structure of fcnLayers was provided in the latest released Matlab, the documentation about fcnLayers seems not clear enough and insufficient. The only example I can find for reference is "Semantic Segmentation Using Deep Learning" that used SegNet. Besides, either SegNet or FCN can take arbitrary size input image, and produce the same size labelled output. The structure that provided in Matlab limited the functions with the fixed size input image. It will be great if there is an example of SegNet or FCN that takes PASCAL VOC data just like it mentioned in the reference papers.

답변 (2개)

Birju Patel
Birju Patel 2018년 2월 23일
In R2017b, we cannot train with arbitrary size images. This is a feature we will consider for a future release. We will also look to add more examples using datasets like PASCAL VOC.
One potential workaround is to use the pixelLabelImageSource with the OutputSizeMode set to 'randcrop' and provide a suitable OutputSize value for training the network. This will ensure that during training the network is trained with objects at their original scale at the cost of losing some of the scene context.
If loss of scene context is not permitted by your application, then you will have to set OutputSize to 'resize'.
See here for more details on the OutputSizeMode and OutputSize properties:
https://www.mathworks.com/help/vision/ref/nnet.cnn.layer.pixellabelimagesource.html

azza elbagoury
azza elbagoury 2018년 4월 15일
why the following error appears when training the fully convolution network. this network is built with (fcnLayers)function??
>>lgraph = fcnLayers(imageSize,numClasses,'type','8s'); >> [net, info] = trainNetwork(datasource,lgraph,options); Training on single CPU. Initializing image normalization.
Error using trainNetwork (line 154) Padding exceeds array bounds. Caused by: Error using builtin Padding exceeds array bounds.
  댓글 수: 2
Birju Patel
Birju Patel 2018년 4월 16일
This is a bug in fncLayers when training on the CPU. GPU training works.
I've attached a script that shows how to workaround this bug by inserting a custom padding layer between the input layer and the first conv layer.
This should let you train on the CPU. However, training an FCN model will be quite slow on the CPU, so beware.
Bhavna Rajasekaran
Bhavna Rajasekaran 2019년 7월 12일
편집: Bhavna Rajasekaran 2019년 7월 12일
The problem is that the workaround allows for padding, but there is conflict between inputsize image fclayers (2 -d input) and trainNetwork. Once the layers are connected, the input size is [ 300 300 3] / [224 224 3].
%% code snippet after reconnecting lgraph from workaround..
inputSize = lgraph.Layers(1,1).InputSize;
imds.ReadFcn = @(loc)imresize(imread(loc),inputSize);
pxds.ReadFcn = @(loc1)imresize(imread(loc1),inputSize);
ds = pixelLabelImageDatastore(imds,pxds);
net = trainNetwork(ds,lgraph,options);
%%
%%trainNetwork gives error!!
Error using ReadFcn @(loc)imresize(imread(loc),inputSize) function handle for file
Error using matlab.images.internal.iptcheckmap (line 55)
Function IMRESIZE expected input number 2, MAP, to be a valid colormap. Valid colormaps cannot have values
outside the range [0,1].
Error in imresize>parsePreMethodArgs (line 366)
matlab.images.internal.iptcheckmap(map, mfilename, 'MAP', 2);
Error in imresize>parseInputs (line 260)
[params.A, params.map, params.scale, params.output_size] = ...
Error in imresize (line 146)
params = parseInputs(args{:});
Error in @(loc)imresize(imread(loc),inputSize)
%%
Something else I missed??
Thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Labeling, Segmentation, and Detection에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by