How to fix error from evaluatesemanticsegmentation function?
1 次查看(过去 30 天)
显示 更早的评论
I used the code for evaluation semantic segmentation in
as shown below:
clc
clear all
dataSetDir = fullfile(toolboxdir('vision'),'visiondata','triangleImages');
testImagesDir = fullfile(dataSetDir,'testImages');
testLabelsDir = fullfile(dataSetDir,'testLabels');
imds = imageDatastore(testImagesDir);
classNames = ["crack","background"];
labelIDs = [255 0];
pxdsTruth = pixelLabelDatastore(testLabelsDir,classNames,labelIDs);
data = load('triangleSegmentationNetwork');
net = data.net
pxdsResults = semanticseg(imds,net,"WriteLocation",tempdir);
metrics = evaluateSemanticSegmentation(pxdsResults,pxdsTruth)
I got the following error:
Error using semanticSegmentationMetrics>iAssertCategoricalsHaveSameCategories (line 1226)
The categorical data returned by dsResults and dsTruth must have the same categories.
Error in semanticSegmentationMetrics/processImages (line 589)
iAssertCategoricalsHaveSameCategories(act,exp,obj.ClassNames);
Error in semanticSegmentationMetrics/processImagesSerial (line 663)
m = processImages(obj,data);
Error in semanticSegmentationMetrics/computeMetrics (line 389)
metrics = processImagesSerial(obj);
Error in semanticSegmentationMetrics (line 195)
[obj, blockMetrics] = obj.computeMetrics();
Error in semanticSegmentationMetrics.compute (line 174)
[obj, blockMetrics] = semanticSegmentationMetrics(varargin{:});
Error in evaluateSemanticSegmentation (line 205)
[metrics, blockMetrics, canComputeBlockMetrics] = semanticSegmentationMetrics.compute(varargin{:});
Error in Gtruth2 (line 13)
metrics = evaluateSemanticSegmentation(pxdsResults,pxdsTruth)
I noted that I have different categories between Result and Truth, but I don’t know how to fix it. I named the attached file same as mentioned in the code on Evaluate semantic segmentation data set against ground truth - MATLAB evaluateSemanticSegmentation (mathworks.com) (triangleImages)
the attached (R7001-60.png) is from testImages folder , the attached (gT7001_60.png) is from testLables folder , both folders in (triangleImages) folder.
How to fix it?
2 个评论
Walter Roberson
2023-12-14
The stored images from data = load('triangleSegmentationNetwork'); are class "triangle" and "background" not "crack" and "background"
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!