How to train Unet semantic segmentation with only one single class/label?
14 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
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)
2 个评论
Matt J
2024-8-6
You're welcome, but please Accept-click the answer to indicate that it resolved your quesiton.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!