Getting both Bounding Boxes and Labels with boxLabelDatastore
Afficher commentaires plus anciens
Hello! I want to train a YOLOv4 NN and and for that I have a trainingData table with three columns, the first with the image name, the second with the bounding boxes and the tird with the labels. The problem is that I'm unable to process both the bounding boxes and the labels into the boxLabelDatastore funtion.
How can I do it? I attach an example of my trainingData table and a bit of my code. Thanks for help in advance!

imdsTrain = imageDatastore(trainingDataTbl{:,"imageFilename"});
bldsTrain = boxLabelDatastore(trainingDataTbl(:,2));
Réponses (1)
Satyam
le 11 Mar 2026
Hi Gonzalo,
To get both the bounding boxes and their corresponding labels into the datastore for training YOLOv4, you can follow these steps:
- Include all the label-related columns from your table when creating the boxLabelDatastore, instead of passing only the bounding box column. For example:
imdsTrain = imageDatastore(trainingDataTbl.imageFilename);
bldsTrain = boxLabelDatastore(trainingDataTbl(:,2:end));
trainingData = combine(imdsTrain,bldsTrain);
- Ensure the label columns contain bounding boxes stored as M×4 numeric arrays for each object class, which is the format expected by boxLabelDatastore when preparing training data
- The combined datastore can then be used directly in the YOLOv4 training workflow as shown in the official example: https://www.mathworks.com/help/vision/ug/object-detection-using-yolov4-deep-learning.html
I hope it resolves your query.
Catégories
En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!