how to create traning,testing table in yolov3 for multiple class?

4 views (last 30 days)
I have the following dataset downloaded from net has an extension of mat file,i am beginner in matalb i dont how to use this data set in yolo object detection?

Answers (2)

yanqi liu
yanqi liu on 17 Jan 2022
yes,sir,may be upload your mat file and images,or check the follow demo
clc; clear all; close all;
load yolov2ResNet50StopSign.mat
I = imread(fullfile(pwd, 'test_data', 'test2.jpg'));
if size(I, 1)/224 < 1
I = imresize(I, size(I, 1)/224+0.5, 'bilinear');
end
[bboxes,scores] = detect(detector,I,'Threshold',0.5);
I = insertObjectAnnotation(I,'rectangle',bboxes,scores,'LineWidth',7);
figure; imshow(I); title('demo');
  2 Comments
tara saber
tara saber on 24 Jan 2022
</matlabcentral/answers/uploaded_files/872455/20220124_235420.jpg> Thanks for your fast reponse dear sir , but still i dont get my answer in my previous mat file the first column is image path while other columns contains bounding box label however matlab yolov3 shower traning data as bounding box label as cell array as i uploded so is there is any way to change the previous uploded file to recent uploded one or there is a way to create a traning data for it ???
yanqi liu
yanqi liu on 25 Jan 2022
yes,may be make self train data,so we should do some label task,use
to get imageLabeler and then process own data

Sign in to comment.


T.Nikhil kumar
T.Nikhil kumar on 9 Jul 2022
Hey Tara!
I understand that you want to use your own dataset in this Object detection using YOLOv3 example.
I want to point out to you that you need to convert your dataset to the required format of object detection. Here is the code to do so. This code is to be written in the Load Data step of the above example link before splitting the dataset into test and training data.
Code:
%Since your data is of struct with fields datatype let us first convert it
%to a table
annotations=struct2table(annotations);
% assuming bbox_x1 and bbox_y1 to be the upper left coordinates of the bounding box and bbox_x2 and bbox_y2 as the lower right coordinates of the bounding box.Creating new width and height columns in the table and populating them by calculating actual height and width values using the following formulae
annotations.width= annotations.bbox_x2- annotations.bbox_x1;
annotations.height= annotations.bbox_y2- annotations.bbox_y1;
%creating a new array spatialCoordinates that contains the spatial coordinates([x y width height]) of each bounding box in cell array format
spatialCoordinates=[];
%creating a new array labels that contains the corresponding labels for
%each bounding box of an image in cell array format.
labels=[];
for i=1:height(annotations)
spatialCoordinates=[spatialCoordinates;{[ annotations.bbox_x1(i) annotations.bbox_y1(i) annotations.width(i) annotations.height(i)]}];
labels=[labels;{ annotations.class(i)}];
end
%converting these arrays to tables and concatenating them with our original
%final table
T1=table(spatialCoordinates);
T2=table(labels);
annotations =[annotations,T1,T2];
%Deleting all the unwanted columns from the finalTable
annotations.bbox_x2=[];
annotations.bbox_y2=[];
annotations.bbox_x1=[];
annotations.bbox_y1=[];
annotations.class=[];
annotations.width =[];
annotations.height =[];
Now you are having a table of image file paths as one column, labels as one column and spatialCoordinates as one column.This is the same structure as the dataset used in the example

Community Treasure Hunt

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

Start Hunting!