Unet not found, problem with deep learning toolbox.

조회 수: 8 (최근 30일)
Eduardo
Eduardo 2025년 8월 11일
댓글: Matt J 2025년 8월 12일
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.

답변 (1개)

Eduardo
Eduardo 2025년 8월 11일
이동: Walter Roberson 2025년 8월 12일
Already solved it. Needed to instal Computer Vision Toolbox. :)
  댓글 수: 1
Matt J
Matt J 2025년 8월 12일
I have found it strange for some time that the Computer Vision Toolbox is needed for such a standard network architecture as unet.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by