Unet not found, problem with deep learning toolbox.

5 ビュー (過去 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