Train a deep learning model with filename in single csv file.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to train U-Net model for an application. Images are having multiple bands saved in different .tif file. To train DL model in MATLAB we require an imagedatastore. But I have filenames for all the images saved in single .csv file, so I'm not able to make a custom 'matReader' function for it.
I have done this when one .csv file contains filenames of different band and mask for a 'single image'. But in this approach I had to make multiple csv files. I want to do the process from a single csv file.
Structure of .csv file is something like:
Image1_B1, Image1_B2...., Mask1
Image2_B1, Image2_B2..., Mask2
.
.
ImageN_B1, ImageN_B2..., MaskN
0 Kommentare
Antworten (1)
Abhijeet
am 3 Apr. 2023
Hi,
You can create a custom matReader function to read the image data from the filenames stored in the csv file, by the following approach:
% Read the csv file into the fileList variable
fileList = readtable('image_file_list.csv');
% The customMatReader function to read the files from the filename variable
function img = customMatReader(filename, imageSize)
img = imread(filename);
img = imresize(img, imageSize);
end
% The size of the images, you should modify it as per your images
imageSize = [256, 256];
% Split the columns in the CSV into separate variables
fileList = splitvars(fileList);
% Create an imageDatastore from the filenames in the CSV file.
% The 'ReadFcn' option specifies a custom function to read the image data from each filename.
% The resulting 'imds' object can be used for training the U-Net model.
imds = imageDatastore(fileList{:,1:end-1}, 'ReadFcn', @(filename) customMatReader(filename, imageSize));
1 Kommentar
Siehe auch
Kategorien
Mehr zu Image Processing and Computer Vision finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!