make data store and boxlabeldatastore from coco dataset

6 vues (au cours des 30 derniers jours)
ahmad
ahmad le 16 Sep 2023
i load -annotation.coco.jason file in matlab by using
jsonFilePath = 'C:\Users\ZBook\Desktop\yolo\train\_annotations.coco.json';
cocoTrainData = loadjson(jsonFilePath);
know i want tpo know how can make imagedatastore and boxlabeldatastore from it to traing yolov4objectdetector

Réponses (1)

T.Nikhil kumar
T.Nikhil kumar le 25 Sep 2023
Hello Ahmad,
I understand that you want to create imageDatastore and boxLabelDatastore for training a YOLO v4 Object Detector network on your custom dataset.
I assume that your COCO JSON annotation is in the standard format and that there are multiple classes(categories) in your dataset.
For Object detection using YOLOv4, we would require the ground truth to be in the form of a table with 3 columns where the first column contains the image file names with paths, the second column contains the bounding boxes, and the third column must be a cell vector that contains the label names corresponding to each bounding box.
Please follow the below workflow to convert the COCO JSON annotation to the required table:
  1. Parse the .json file to a string format using fileread function and then extract info from it in the form of a struct using the jsondecode function.
  2. Go to the “annotations” struct in the struct formed via “jsondecode and loop through the fields of this “annotations” struct to access the “image_id”,category_id” and the “bbox” values for each field.
  3. Create a table in your “.m” file where you are working on the YOLOv4 network and populate it with entries containing the image File path, bounding box coordinates and category label. Note that the image File path should be a string, the bounding box coordinates should be a [1X4] array and the category label must be a cell vector containing the category name for each entry.
Now, you can create the image datastore using the “imageDatastore” function and the box label datastore using the “boxLabelDatastore” function.
imds = imageDatastore(dataTable.imageFilePath);
blds = boxLabelDatastore(dataTable(:, 2:end));
Note that the box label datastore will contain the bounding box coordinates as well as the category labels.
You can refer to the below documentation to understand more about creating tables in MATLAB.
You can refer to the below documentation to understand about an example of Object Detection using YOLOv4.
You can refer to the below documentation to understand more about jsondecode function in MATLAB.
I hope this helps!

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by