Unet not found, problem with deep learning toolbox.

7 Ansichten (letzte 30 Tage)
Eduardo
Eduardo am 11 Aug. 2025
Kommentiert: Matt J am 12 Aug. 2025
I am trying to start training my neural network but Matlab r2024b is not recognizing the Unet function, even with the toolbox properly instaled.
It's displaying the following error:
Unrecognized function or variable 'unet'.
Error in U_net_training (line 42)
lgraph = unet(inputSize, numClasses,'EncoderDepth', encoderDepth);
Going to leave the error path of the code here:
%% U-net training
clear
clc
load('pretrained_unet.mat');
% Load images and masks
original_images_dir = 'C:\Users\edusr\Desktop\Image Processing\Exportedimages15_1';
mask_dir = 'C:\Users\edusr\Desktop\Image Processing\Mask15_1';
images = dir(fullfile(original_images_dir, '*.tif'));
masks = dir(fullfile(mask_dir, '*.tif'));
% Resize images and masks to compatible dimensions
targetSize = [304, 832]; % Compatible dimensions (multiples of 16)
for i = 1:numel(images)
imgPath = fullfile(images(i).folder, images(i).name);
maskPath = fullfile(masks(i).folder, masks(i).name);
% Read and resize images
resizedImage = imresize(imread(imgPath), targetSize);
resizedMask = imresize(imread(maskPath), targetSize);
% Save resized images and masks (optional)
imwrite(resizedImage, imgPath);
imwrite(resizedMask, maskPath);
end
% Split into training and validation sets
[trainImages, valImages, trainMasks, valMasks] = splitData(images, masks, 0.7);
% Define U-Net architecture
firstImage = imread(fullfile(images(1).folder, images(1).name));
inputSize = [304, 832, 1]; % Assuming grayscale images
numClasses = 2; % Background and bubble
% Define U-Net architecture using unet function
encoderDepth = 4; % Default encoder depth
lgraph = unet(inputSize, numClasses,'EncoderDepth', encoderDepth);
If someone could help it would be kindly apreciated.

Antworten (1)

Eduardo
Eduardo am 11 Aug. 2025
Verschoben: Walter Roberson am 12 Aug. 2025
Already solved it. Needed to instal Computer Vision Toolbox. :)
  1 Kommentar
Matt J
Matt J am 12 Aug. 2025
I have found it strange for some time that the Computer Vision Toolbox is needed for such a standard network architecture as unet.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by