How can I fix an index error in my code for training a semantic segmentation network?
3 views (last 30 days)
Show older comments
I tweaked the existing semantic segmentation example so that I could use my own annotations and images. However, every time I run the code, I keep getting an error that an index of some sort is out of bounds (<=59 to be exact, see the screenshot attached). I traced the stack and found that the number of annotations was 59, while the number of images was 60. I was able to find that I had not annotated one of the images. After fixing this and reexporting the ground truth file, the index error was now <=60. I have attached my code and the groundTruth file I exported from the MATLAB imageLabeler tool. I was wondering if there is an index or list somewhere that I am missing.
2 Comments
Sai Pavan
on 27 May 2024
Please provide the dataset i.e., both the images and the labels so that we can run the modified example file as the "gTruth_fixed" MAT file only contains the path to images and not the images themselves.
Answers (1)
Sachin Lodhi
on 14 Jun 2024
Hi Lamine,
I have identified the cause of the error you are encountering during the training of your semantic segmentation network. It appears that the 'groundTruth' file created with the MATLAB Image Labeler App contains labels for only up to 60 images. This discrepancy arises because the 'groundTruth' file was generated using just 60 images, but the total number of original images in your dataset are 120. In 'partitionCamVidData' function 'shuffledIndices' are a random permutation of indices from 1 to 120. Consequently, 'trainingIdx', 'valIdx' and 'testIdx' can have values greater than 60. Partiioning the ground truth data using these set of indices is not possible as it only has 60 labelled images.
To rectify this issue, you could either:
- Extend the groundTruth file to encompass all 120 images by utilizing the MATLAB Image Labeler App.
- Only include those 60 images in the image data which corresponds to the labelled images in ground truth.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!