training semantic segmentation for grayscale

조회 수: 4 (최근 30일)
Yuchun Ding
Yuchun Ding 2020년 2월 11일
답변: KH TOHIDUL ISLAM 2021년 6월 29일
Hi, I'm trying to modify the semantic segmetation example by Matlab to make it work with grayscale image
I think it might involve modifying the nutral network to make it work with the grayscale image for training the model.
please suggest how :)

답변 (2개)

Srivardhan Gadila
Srivardhan Gadila 2020년 2월 18일
From the layerGraph, replace the imageInputLayer with new imageInputLayer having value 1 in channel dimension. Make use of the function analyzeNetwork to check for any errors and replace the layers accordingly. Then convert all images of the dataset from RGB to Grayscale.
For the network used in the Example: Semantic Segmentation Using Deep Learning, make the following changes:
imageSize = [720 960 3];
lgraph = deeplabv3plusLayers(imageSize, numClasses, "resnet18");
layers = lgraph.Layers
analyzeNetwork(lgraph)
%% Replace layers and create new layerGraph
newlgraph = replaceLayer(lgraph,'data',imageInputLayer([720 960 1],'Name','input'));
newlgraph = replaceLayer(newlgraph,'conv1',convolution2dLayer(7,64,'stride',[2 2],'padding',[3 3 3 3],'Name','conv1'))
analyzeNetwork(newlgraph)
Use the newlgraph for training on grayscale images.

KH TOHIDUL ISLAM
KH TOHIDUL ISLAM 2021년 6월 29일
You can use the following function!
pximdsResz = pixelLabelImageDatastore(imds,pxds,'OutputSize',imageSize,...
'ColorPreprocessing','gray2rgb');

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by