Understanding the use of data in Object Detection

12 views (last 30 days)
Yonathan Zarkovian
Yonathan Zarkovian on 6 Oct 2021
Hi,
I have a question regarding the 'load data' section in this code, which was taken from the Yolo v3 object detection guide here.
The example uses images of vehicles. It has a Ground Truth file for that, and also a dataset.
I can see the Ground Truth file in the MATLAB folder, but I don't understand where it's taking the dataset from. I'm not sure I understand the difference between a dataset and Ground Truth data.
What I'd like to do is to change the code so that it detects faces instead of vehicles.
I have downloaded a dataset called 'CelebA'. I now have a folder that contains images of faces, they're numbered 000001, 000002, etc...
There's also a text file that contains many lines, each containing an image file name and coordinates for its boundary box (I assume the coordinates mark the location of the face in the image, so it's part of the ground truth data).
I need to somehow load the ground truth data into matlab, as well as the dataset.
I'd appreciate help with implementing this change.
Thank you.
%% download pretrained network (set to 'true' to train the network)
doTraining = false;
if ~doTraining
preTrainedDetector = downloadPretrainedYOLOv3Detector();
end
%% load data (modify to faces dataset)
data = load('vehicleDatasetGroundTruth.mat');
vehicleDataset = data.vehicleDataset;

Answers (1)

Prateek Rai
Prateek Rai on 9 Oct 2021
To my understanding, you want to learn how the dataset is loaded and used in Yolo v3 object detection MATLAB example. Further, you want to use your own data to train Yolo v3 object detection model.
Part 1:
%% download pretrained network (set to 'true' to train the network)
doTraining = false;
if ~doTraining
preTrainedDetector = downloadPretrainedYOLOv3Detector();
end
This part of code is used to decide whether you want to train the network or use the pretrained network. Set 'doTraining' to 'true' to train the network.
Part 2:
%% load data (modify to faces dataset)
data = load('vehicleDatasetGroundTruth.mat');
vehicleDataset = data.vehicleDataset;
Here, 'data' variable will store mat file which in turn is a 1×1 struct with 1 field i.e. vehicleDataset.
Now, 'vehicleDataset' variable will store main dataset which is a 295*2 table. Column 1 contain location path of image files and column 2 contain bounding box coordinates. This bounding boxes specifies the upper left corner and the size of the bounding box in pixels. The bounding boxes are in the form [x y width height].
Now, if you want to use your data you have to apply following changes.
Step 1: You create a table in which:
  • first column should contain the location paths of your images.
  • second column should contain the bounding box vector as per specified format.
Step 2: Set 'vehicleDataset' variable to this newly created table.
  5 Comments
Yonathan Zarkovian
Yonathan Zarkovian on 24 Oct 2021
Does usig the Train function replace the original training that was done on the COCO database, or does it add to it, like transfer training?
By the way, I get this error when I set doTraining to 'true':
'generateTargets' is used in Object Detection Using YOLO v3 Deep Learning.
Error in modelGradients (line 11)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = generateTargets(gatheredPredictions,...
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in dlfeval (line 40)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in yolov3_Copy (line 110)
[gradients, state, lossInfo] = dlfeval(@modelGradients, yolov3Detector, XTrain, YTrain, penaltyThreshold);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!