How to fix error from evaluatese​manticsegm​entation function?

조회 수: 1 (최근 30일)
yasmin ismail
yasmin ismail 2023년 10월 4일
댓글: Walter Roberson 2023년 12월 14일
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
net =
SeriesNetwork with properties: Layers: [10×1 nnet.cnn.layer.Layer] InputNames: {'imageinput'} OutputNames: {'classoutput'}
pxdsResults = semanticseg(imds,net,"WriteLocation",tempdir);
Running semantic segmentation network ------------------------------------- * Processed 100 images.
metrics = evaluateSemanticSegmentation(pxdsResults,pxdsTruth)
Evaluating semantic segmentation results ---------------------------------------- * Selected metrics: global accuracy, class accuracy, IoU, weighted IoU, BF score. * Processed 0 images.
Error using semanticSegmentationMetrics>iAssertCategoricalsHaveSameCategories
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{:});
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
Natthapat Kijpoonphol
Natthapat Kijpoonphol 2023년 12월 14일
I got the same problem, anyone please can you help us ?
Walter Roberson
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!

Translated by