where can I get pretrained unet, pixelnet, segnet deconvnet matlab codes for CT lung cancer segmentation?

4 views (last 30 days)
This code fragment causes an error in the decoder and output layer. It provides a derror in the transponse layers of decoder and output layer, concatenation layers of the decoder, relu layerS of decoder and outputlayer and additional input missing and no input connection errors correspondigly.
% Define the UNet architecture
% Define input image size
inputSize = [120 150];
% Number of filters in the first layer
numFilters = 64;
% Number of segmentation classes
numClasses = 2;
% Define encoder layers
encoder_layers = [
imageInputLayer(inputSize)
convolution2dLayer(3, numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, numFilters, 'Padding', 'same')
reluLayer()
maxPooling2dLayer(2, 'Stride', 2)
convolution2dLayer(3, 2*numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, 2*numFilters, 'Padding', 'same')
reluLayer()
maxPooling2dLayer(2, 'Stride', 2)
convolution2dLayer(3, 4*numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, 4*numFilters, 'Padding', 'same')
reluLayer()
maxPooling2dLayer(2, 'Stride', 2)
convolution2dLayer(1, numClasses, 'Name', 'output')
softmaxLayer('Name', 'softmax')
pixelClassificationLayer('Name', 'pixel_class')
];
% Define decoder layers
decoder_layers = [
transposedConv2dLayer(2, 2*numFilters, 'Stride', 2)
reluLayer()
concatenationLayer(3, 2, 'Name', 'concat_1'); % Connect to maxPooling2dLayer in encoder
convolution2dLayer(3, 2*numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, 2*numFilters, 'Padding', 'same')
reluLayer()
transposedConv2dLayer(2, numFilters, 'Stride', 2)
reluLayer()
concatenationLayer(3, 2, 'Name', 'concat_2'); % Connect to maxPooling2dLayer in encoder
convolution2dLayer(3, numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, numFilters, 'Padding', 'same')
reluLayer()
transposedConv2dLayer(2, numFilters/2, 'Stride', 2)
reluLayer()
concatenationLayer(3, 2, 'Name', 'concat_3'); % Connect to maxPooling2dLayer in encoder
convolution2dLayer(3, numFilters/2, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, numFilters/2, 'Padding', 'same')
reluLayer()
];
outputLayer = [
concatenationLayer(3, 2, 'Name', 'concat_3') % Connect to maxPooling2dLayer in encoder
transposedConv2dLayer(2, numFilters/2, 'Stride', 2)
reluLayer()
convolution2dLayer(3, numFilters/2, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, numFilters/2, 'Padding', 'same')
reluLayer()
concatenationLayer(3, 2, 'Name', 'concat_2') % Connect to maxPooling2dLayer in encoder
transposedConv2dLayer(2, numFilters, 'Stride', 2)
reluLayer()
convolution2dLayer(3, numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, numFilters, 'Padding', 'same')
reluLayer()
concatenationLayer(3, 2, 'Name', 'concat_1') % Connect to maxPooling2dLayer in encoder
transposedConv2dLayer(2, 2*numFilters, 'Stride', 2)
reluLayer()
convolution2dLayer(3, 2*numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(3, 2*numFilters, 'Padding', 'same')
reluLayer()
convolution2dLayer(1, numClasses, 'Name', 'output')
softmaxLayer('Name', 'softmax')
pixelClassificationLayer('Name', 'pixel_class')
];
output_network = layerGraph(outputLayer);
% Analyze the network to check output sizes
analyzeNetwork(output_network);
Error using analyzeNetwork
This functionality is not available on remote platforms.
  2 Comments
Walter Roberson
Walter Roberson on 4 Mar 2024
You do not use encoder_layers or decoder_layers after you declare them.
It is correct that inside what you have labeled outputLayer that you do not have any output layer.
Abel Belay
Abel Belay on 5 Mar 2024
this was a code fragment only specifying the layers, I did use them.
layers = [
encoder_layers
decoder_layers
% convolution2dLayer(1, numClasses)
% softmaxLayer()
pixelClassificationLayer('Name', 'pixel_class')
];
pixellabel = [0 255];
categories = {'Lung', 'Tumor'};
imdsTrain = imageDatastore('D:\trainingimages');
pxdsTrain = pixelLabelDatastore('D:\masks',categories, pixellabel);
imdsValidation = imageDatastore('D:\validation');
pxdsValidation = pixelLabelDatastore('D:\validationlabel',categories, pixellabel);
trainData = pixelLabelImageDatastore(imdsTrain, pxdsTrain);
valData = pixelLabelImageDatastore(imdsValidation, pxdsValidation);
options = trainingOptions('adam', ...
'MaxEpochs', 50, ...
'MiniBatchSize', 16, ...
'Shuffle', 'every-epoch', ...
'InitialLearnRate', 1e-3, ...
'Verbose', true, ...
'Plots', 'training-progress', ...
'ValidationData', {imdsValidation, pxdsValidation});
net = trainNetwork(trainData, layers, options);
but the trainNetwork command has caused "unconnected input) in several connections.

Sign in to comment.

Answers (0)

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!