pixels imbalance of classes in ground truth image used in CNN training for semantic segmentation
3 次查看(过去 30 天)
显示 更早的评论
Hello guys i hope you are all well.
I am really in urgent need for your help. i want to ask about pixels imbalance in images during training CNN for semantic segmentation. image and its corresponding ground truth are shown below. as we can see in the ground truth 0 represnets background pixels, 128 is for left ventricle cavity pixels, 255 is for myocardium. so, i ignored background pixels as depicted in code below during CNN training, but the training and testing accuracies are between 70 -80% percent only.
dataSetDir = fullfile('G:\My Drive\sem5\EMIDEC database\Case_P001\new_data_for_LVMYO');
imageDir = fullfile(dataSetDir,'images');
labelDir = fullfile(dataSetDir,'contours');
imds = imageDatastore(imageDir);
% c=readimage(imds,30);
classNames = ["LV" "Myo"];
labelIDs = [128 255];
pxds = pixelLabelDatastore(labelDir,classNames,labelIDs);
i have trained the network with background pixel (0) as shown in code below, but the testing accuracy is low while training accuracy is acceptable.
my question is how to deal with this issue, sholud i exlcude the background pixels during training CNN , if so how to increase the accuracies?
thanks in advance.
dataSetDir = fullfile('G:\My Drive\sem5\EMIDEC database\Case_P001\new_data_for_LVMYO');
imageDir = fullfile(dataSetDir,'normalized_training_images');
labelDir = fullfile(dataSetDir,'normalized_training_contours');
imds = imageDatastore(imageDir);
% c=readimage(imds,30);
classNames = ["background" "LV" "Myo"];
labelIDs = [0 128 255];
pxds = pixelLabelDatastore(labelDir,classNames,labelIDs);
image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/718124/image.png)
ground truth(label)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/718129/image.png)
0 个评论
回答(2 个)
Srivardhan Gadila
2021-10-6
You can refer to Balance Classes Using Class Weighting from the Semantic Segmentation Using Deep Learning example or replace the loss layer with focalLossLayer.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!