how can i load dataset for object detection from desktop to matlab for yolo training

9 views (last 30 days)
hi every.
i am facing prblem in loading darknet dataset folder into matlab. i can read images and annotation values but when i store annotation values it shows error that it should be in table i do convert to table but it nor convert in to tables.moreover i also want that it lead my labels file and display label name with annotation values or bounding vaues . my dataset look like this screanshot attached

Answers (1)

Sachin
Sachin on 13 Sep 2023
Hi ahmad,
I understand that you want to load the dataset from the desktop for yolo training. To achieve the same kindly, refer to the following steps -
  1. Create a ‘mat’ file with the help of data images and annotations. Refer to the MathWorks documentation: https://in.mathworks.com/help/deeplearning/ug/object-detection-using-yolo-v2.html
  2. Create a Yolo object detector. Refer to the following MathWorks documentation to know more about object detection: https://in.mathworks.com/help/vision/ref/yolov2objectdetector.html
  3. Train your Yolo model with the help of a dataset and an object detector. To know more about training a Yolo model refer to the following documentation - https://in.mathworks.com/help/vision/ref/trainyolov2objectdetector.html#mw_1ac406b2-0df3-43b6-848e-42e7a69b79b2
  4. Now with the help of the ‘insertObjectAnnotation’ function, add the class label and bounding box to the result. Refer to the following documentation to know more about the ‘insertObjectAnnotation’ function - https://in.mathworks.com/help/vision/ref/insertobjectannotation.html#btilxte-1-I
Hope it help!!
Thanks
Sachin
  3 Comments
ahmad
ahmad on 18 Sep 2023
Hi sir, I tried to makes .mat file from my dataset present on desktop folder but can't able to make it ( I am doing object detection by yolo).so is there way to make it.
Vivek Akkala
Vivek Akkala on 28 Sep 2023
Hi Ahmad,
To read the data into MATLAB and create the .mat file, you can follow these steps:
1. First, read the data into MATLAB using suitable functions such as `readtable`, `load`, or `importdata`, depending on the file format.
2. Once the data is loaded, create a table in MATLAB with two columns. Column 1 should contain the image filenames, and column 2 should contain the corresponding ground truth data. The table format is mentioned in the Object detection using YOLO v2 deep learning example.
3. If you have already created the table with the desired structure, there is no need to create a separate .mat file. You can directly use the table for training the YOLO detector. You may refer to the below steps to read the data into MATLAB:
Step 1: Get image files names use the following commands:
dataPath = 'absolute or relative path to where the files are saved';
dataFileNames = dir(fullfile(dataPath,'*.jpg'))
dataFileNames is a structure with dataFileNames.name having all the image file names.
Step 2: Read the groundtruth data using the following command:
textFileNames = dir(fullfile(dataPath,'*.txt'));
textFileNames is a structure with textFileNames.name having all the groundTruth data mentioned in the text file.
You can then extract the data from these structures and convert them into Table format.
You may further refer to following docs for more information:

Sign in to comment.

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!