(I have provided a workaround in comments but it is no answer) Matlab example "Train Deep Learning Semantic Segmentation Network Using 3-D Simulation Data" doesn't work.
조회 수: 3 (최근 30일)
이전 댓글 표시
Note: If it is not clear in my original post... then let me clarify that the folders are empty. Therefore IncludeSubfolders cannot fix this as there is no subfolder to search for. We are already looking at the most "sub" subfolder possible. Also, I have an intuition regarding what the issue might be but didn't wanna say it to make room for other ideas. My intuition says the problem lies in (a helper function) downloadDataset's last sections where it copies and splits the full data into the specified subfolders created. Note that we are already looking at them without the need for IncludeSubfolders. So setting it to "True" can't fix the issue. While I have an idea where the problem lies... I am quite unqualified to fix this example MATLAB documentation has provided. Further note that the issue has nothing to do with my local environment as it doesn't work on MATLAB cloud either.
Edit: I re-run the script through cloud rather than a local machine and the exact same error happened.
Original post: I have tested the example and found out that the data splitting of real data doesn't properly happen despite the successful creation of its folders. This, in turn, makes the example broken and unusable. Since the split never happens, there is no splitted data in the folders and thus the error is a generic error as expected. I did not altered the code. The link for this example is https://www.mathworks.com/help/deeplearning/ug/train-deep-learning-semantic-segmentation-network-using-3d-simulation-data.html
Folder 'C:\...\AppData\Local\Temp\RealData\train\images' does not have any files or is empty.
Use 'IncludeSubfolders' to include files in all subfolders.
This error comes from the line below:
realData = imageDatastore(realImagesFolder);
I want to be able to run this example.
Edited Note-2: I found the issue with the helper function. I am copying the helper code in its entirety to show you the original. A possible solution will be provided in the answers. (A solution couldn't provided but there is a workaround, I will not accept the workaround as an answer. So that this question can be answered properly by someone else.)
function [simulationImagesFolder, simulationLabelsFolder, realImagesFolder, realLabelsFolder,...
realTestImagesFolder, realTestLabelsFolder] = ...
downloadDataset(simulationDataLocation, simulationDataURL, realDataLocation, realImageDataURL, realLabelDataURL)
% Build the training image and label folder location for simulation data.
simulationDataZip = fullfile(simulationDataLocation,'SimulationDrivingDataset.zip');
% Get the simulation data if it does not exist.
if ~exist(simulationDataZip,'file')
mkdir(simulationDataLocation)
disp('Downloading the simulation data');
websave(simulationDataZip,simulationDataURL);
unzip(simulationDataZip,simulationDataLocation);
end
simulationImagesFolder = fullfile(simulationDataLocation,'SimulationDrivingDataset','images');
simulationLabelsFolder = fullfile(simulationDataLocation,'SimulationDrivingDataset','labels');
camVidLabelsZip = fullfile(realDataLocation,'CamVidLabels.zip');
camVidImagesZip = fullfile(realDataLocation,'CamVidImages.zip');
if ~exist(camVidLabelsZip,'file') || ~exist(camVidImagesZip,'file')
mkdir(realDataLocation)
disp('Downloading 16 MB CamVid dataset labels...');
websave(camVidLabelsZip, realLabelDataURL);
unzip(camVidLabelsZip, fullfile(realDataLocation,'CamVidLabels'));
disp('Downloading 587 MB CamVid dataset images...');
websave(camVidImagesZip, realImageDataURL);
unzip(camVidImagesZip, fullfile(realDataLocation,'CamVidImages'));
end
% Build the training image and label folder location for real data.
realImagesFolder = fullfile(realDataLocation,'train','images');
realLabelsFolder = fullfile(realDataLocation,'train','labels');
% Build the testing image and label folder location for real data.
realTestImagesFolder = fullfile(realDataLocation,'test','images');
realTestLabelsFolder = fullfile(realDataLocation,'test','labels');
% Partition the data into training and test sets if they do not exist.
if ~exist(realImagesFolder,'file') || ~exist(realLabelsFolder,'file') || ...
~exist(realTestImagesFolder,'file') || ~exist(realTestLabelsFolder,'file')
mkdir(realImagesFolder);
mkdir(realLabelsFolder);
mkdir(realTestImagesFolder);
mkdir(realTestLabelsFolder);
% Load the mat file that has the names for testing and training.
partitionNames = load('subsetCamVidDatasetFileNames.mat');
% Extract the test images names.
imageTestNames = partitionNames.imageTestNames;
% Remove the empty cells.
imageTestNames = imageTestNames(~cellfun('isempty',imageTestNames));
% Extract the test labels names.
labelTestNames = partitionNames.labelTestNames;
% Remove the empty cells.
labelTestNames = labelTestNames(~cellfun('isempty',labelTestNames));
% Copy the test images to the respective folder.
for i = 1:size(imageTestNames,1)
labelSource = fullfile(realDataLocation,'CamVidLabels',labelTestNames(i));
imageSource = fullfile(realDataLocation,'CamVidImages','701_StillsRaw_full',imageTestNames(i));
copyfile(imageSource{1}, realTestImagesFolder);
copyfile(labelSource{1}, realTestLabelsFolder);
end
% Extract the train images names.
imageTrainNames = partitionNames.imageTrainNames;
% Remove the empty cells.
imageTrainNames = imageTrainNames(~cellfun('isempty',imageTrainNames));
% Extract the train labels names.
labelTrainNames = partitionNames.labelTrainNames;
% Remove the empty cells.
labelTrainNames = labelTrainNames(~cellfun('isempty',labelTrainNames));
% Copy the train images to the respective folder.
for i = 1:size(imageTrainNames,1)
labelSource = fullfile(realDataLocation,'CamVidLabels',labelTrainNames(i));
imageSource = fullfile(realDataLocation,'CamVidImages','701_StillsRaw_full',imageTrainNames(i));
copyfile(imageSource{1},realImagesFolder);
copyfile(labelSource{1},realLabelsFolder);
end
댓글 수: 0
답변 (2개)
Shreeya
2024년 5월 9일
Hello
A quick look at the error suggests that the content inside the folder is not included in the path and is not accessible, causing the error. The "imageDatastore" accepts the argument ""IncludeSubfolders" as the subfolder inclusion flag. Specify this as true to include all files and subfolders within each folder. You can have a look at the link below for further reference
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel and Cloud에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!