Unet code after training output response is same as that of input

1 visualización (últimos 30 días)
Manjunath R V
Manjunath R V el 14 de Dic. de 2020
Comentada: Manjunath R V el 14 de Dic. de 2020
Hello sir this is the Unet code am using to train the 256x256 size CT images.
when i tested the code after training, output image will be same as that of input image. it is unable to segment the liver from the CT image. Here am attaching the code as well as an input and output image please do the needfull.
clc
clear all
close all
load gTruth.mat
% currentPathPixels = "C:\RVM\code_with_image_labl\Unet\PixelLabelData";
% newPathPixels = fullfile('C:\RVM\code_with_image_labl\Unet\liverPixelLabels');
% alternativePaths = {[currentPathPixels newPathPixels]};
% unresolvedPaths = changeFilePaths(gTruth,alternativePaths)
% Load training images and pixel labels into the workspace.
dataSetDir = fullfile('C:\RVM\code_with_image_labl\Unet'); %%Change the the path before run the code
imDir = fullfile(dataSetDir,'Inp_256');
pxDir = fullfile(dataSetDir,'lab256');
% Create an imageDatastore object to store the training images.
Original_imageData = imageDatastore(imDir);
% Define the class names and their associated label IData_set.
classNames = ["background","Abdomen","Liver"];
labelIData_set = [0 1 2];
% labelIData_set = cell(3,1);
% labelIData_set{1,1} = [2;0];
% labelIData_set{2,1} = 1;
% labelIData_set{3,1} = 3;
% Create a pixelLabelDatastore object to store the ground truth pixel labels for the training images.
Segmented_imageData = pixelLabelDatastore(pxDir,classNames,labelIData_set);
% Create the U-Net network.
imageSize = [256 256 1];
numClasses = 3;
Unet_Strct = unetStracture(imageSize, numClasses);
% Create a datastore for training the network for training a semantic segmentation network using deep learning
Data_set = pixelLabelImageDatastore(Original_imageData,Segmented_imageData);
% Set training options.
% % options = trainingOptions('sgdm', ...
% % 'InitialLearnRate',1e-3, ...
% % 'MaxEpochs',10, ...
% % 'VerboseFrequency',10);
options = trainingOptions('sgdm', ...
'Momentum',0.9, ...
'InitialLearnRate',8e-4, ...
'L2Regularization',0.0005, ...
'MaxEpochs',50, ...
'MiniBatchSize',3, ...
'Shuffle','every-epoch', ...
'CheckpointPath', tempdir, ...
'VerboseFrequency',2, ...
'Plots','training-progress');
% Train the network.
newcode_net = trainNetwork(Data_set,Unet_Strct,options)
%Trained data will be saved
save newcode_net newcode_net;
  1 comentario
Manjunath R V
Manjunath R V el 14 de Dic. de 2020
can anybody help me how to segment the liver part from the image also wanted know what changes should i make in the above code to obtain the unet as 53 layers

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by