Train a deep learning model with filename in single csv file.
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Abhijeet
2023 年 4 月 3 日
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));
参考
カテゴリ
Help Center および File Exchange で Image Processing and Computer Vision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!