Hi!
I understand that you are trying to create an augmented datastore by providing a table of predictors and responses to the "augmentedImageDatastore" function. However, you are encountering an error message stating "Unexpected image path," which indicates that there might be an issue with the image paths you are using.
It appears that the error is caused by incorrect or invalid image paths when using the “augmentedImageDatastore” function with a table as input. In this case, the table should contain absolute or relative image paths in its first column.
To resolve the error, it is important to double-check the entries in the table and ensure that they contain the correct image paths. Location of the images may vary depending on the system and the current working directory. Therefore, using the example path directly may not be appropriate for your specific setup.
Here's a short working example that demonstrates the process of generating random images, saving them in a folder, reading the images back, storing their locations in a table, and finally creating an “augmentedImageDatastore” using the table.
% Create a new folder to store the generated images
mkdir('TrainImages');
imageSize = [128, 128];
% Generate and save 5 random images
for i = 1:5
% Generate a random image
randomImage = randi([0, 255], imageSize, 'uint8');
% Create a filename for the image
filename = sprintf('TrainImages/random_image_%d.png', i);
% Save the image
imwrite(randomImage, filename);
end
folderPath = 'TrainImages'; % Specify the folder path
% Get a list of all files in the folder
fileList = dir(fullfile(folderPath, '*.png')); % Change the extension if needed
filenames = {};
% Loop through the files and store the filenames in a cell array
for i = 1:numel(fileList)
filename = fullfile(folderPath, fileList(i).name);
filenames = [filenames, filename];
end
% Create a table with the filenames
tblFilenames = table(filenames', 'VariableNames', {'Filename'});
inputSizeNet = [64, 64, 3];
% Create an augmentedImageDatastore
augimdsTrain = augmentedImageDatastore(inputSizeNet, tblFilenames, 'ColorPreprocessing', 'gray2rgb');
Additionally, I am including the structure of the current working directory to provide a clearer understanding.
For further information on the "augmentedImageDatastore" function, you can refer to the following link:
To learn more about the "fullfile" function, you can refer to the following link:
Hope this helps.