How to train Unet semantic segmentation with only one single class/label?

조회 수: 12 (최근 30일)
Al
Al 2024년 8월 6일
댓글: Matt J 2024년 8월 6일
Hello, I'm currently working on a task to do a semantic segmentation on USG image to locate TMJ. I did my image labelling in Image Labeler App and only did one class so that the class region will be 1 and background is 0. I was about to train my model with unetLayers but it says "The value of 'numClasses' is invalid. Expected numClasses to be a scalar with value > 1."
I'm aware that someone asked this similar question here with an answer, but I want to ask, how to customize specifically unetLayers to accomodate single class? I see that unetLayers also has softmaxLayers but i can't find the pixel layers. Thank you in advance!

답변 (1개)

Matt J
Matt J 2024년 8월 6일
편집: Matt J 2024년 8월 6일
The value of 'numClasses' is invalid. Expected numClasses to be a scalar with value > 1
Because you have two classes (0 and 1). There is no such thing as a single class.
I see that unetLayers also has softmaxLayers but i can't find the pixel layers. Thank you in advance!
Where are you looking? The final layer should be the Pixel Classification Layer, as in the following example,
imageSize = [480 640 3];
numClasses = 5;
encoderDepth = 3;
lgraph = unetLayers(imageSize,numClasses,'EncoderDepth',encoderDepth);
lgraph.Layers(end-5:end)
ans =
6x1 Layer array with layers: 1 'Decoder-Stage-3-ReLU-1' ReLU ReLU 2 'Decoder-Stage-3-Conv-2' 2-D Convolution 64 3x3 convolutions with stride [1 1] and padding 'same' 3 'Decoder-Stage-3-ReLU-2' ReLU ReLU 4 'Final-ConvolutionLayer' 2-D Convolution 5 1x1 convolutions with stride [1 1] and padding 'same' 5 'Softmax-Layer' Softmax softmax 6 'Segmentation-Layer' Pixel Classification Layer Cross-entropy loss
  댓글 수: 2
Al
Al 2024년 8월 6일
편집: Al 2024년 8월 6일
Thank you so much! I think I was panicking with my assignment so I didn't properly notice the layers
Matt J
Matt J 2024년 8월 6일
You're welcome, but please Accept-click the answer to indicate that it resolved your quesiton.

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

카테고리

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