pixels imbalance of classes in ground truth image used in CNN training for semantic segmentation

1 view (last 30 days)
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
ground truth(label)

Answers (2)

yanqi liu
yanqi liu on 30 Sep 2021
sir,may be use some data augument to increase image data

Srivardhan Gadila
Srivardhan Gadila on 6 Oct 2021
You can refer to Balance Classes Using Class Weighting from the Semantic Segmentation Using Deep Learning example or replace the loss layer with focalLossLayer.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!