how to create traning,testing table in yolov3 for multiple class?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/863200/20220114_225902.jpg)
0 Kommentare
Antworten (2)
yanqi liu
am 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 Kommentare
yanqi liu
am 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
T.Nikhil kumar
am 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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing and Computer Vision finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!