Create custom people detector for automated labelling on own specific dataset
Show older comments
I have applied the built-in ACFpeopleDetector for automated labelling on my own dataset of people in a rail station (not upright still images) and it is not very accurate. I have also tried to create and train a custom ACFobjectDetector (307 training images for 3075 dataset) but is not an improvement. Is there a way to pre-process (like instance segmentation) a dataset of people in a rail station to make the labelling more accurate? The dataset is people walking through a specific area at an overhead angle and thus the frames are not perfectly still images of people and many times with people behind one another.
Answers (2)
Mahesh Taparia
on 4 Oct 2021
0 votes
Hi
In order to label the objects, you can use image labeler app with custom algorithm option.The custom algorithm can be YOLOv3/ FasterRCNN/ any deep learning network pretrained on COCO dataset. For more information on custom algorithm approach, you can refer to this documentation and this example. Try to use YOLO3,it may work in your case.
Hope it will help!
Candice Earley
on 6 Oct 2021
0 votes
3 Comments
Mahesh Taparia
on 7 Oct 2021
Hi
You can use a custom algorithm option while doing labeling, for example you can use YOLOv3 in your case as follows:
- Save the below code in your current working directory,
- Select this file as automation algorithm in image/video labeler
- Click on automate button, it will create prediction as per YOLOv3 (you can use any other algorithm in place of that).
- Adjust the prediction if they are not proper.
- Save/ export the labels as gTruth object.
classdef MyCustomAlgorithmForLabeling < vision.labeler.AutomationAlgorithm & vision.labeler.mixin.Temporal
properties(Constant)
% Name: Give a name for your algorithm.
Name = 'Example YOLOv3 Algorithm';
% Description: Provide a one-line description for your algorithm.
Description = 'This is an example of a custom automation algorithm.';
UserDirections = {...
vision.labeler.AutomationAlgorithm.getDefaultUserDirections('selectroidef', vision.getMessage('vision:labeler:People')),...
vision.labeler.AutomationAlgorithm.getDefaultUserDirections('rundetector', vision.getMessage('vision:labeler:People')),...
vision.labeler.AutomationAlgorithm.getDefaultUserDirections('review'),...
vision.labeler.AutomationAlgorithm.getDefaultUserDirections('rerun'),...
vision.labeler.AutomationAlgorithm.getDefaultUserDirections('accept')...
};
end
properties
%------------------------------------------------------------------
% Place your code here
%------------------------------------------------------------------
detector
SelectedLabelName
end
methods
function isValid = checkLabelDefinition(~, labelDef)
%--------------------------------------------------------------
% Place your code here
isValid = (labelDef.Type == labelType.Rectangle);
%--------------------------------------------------------------
end
end
methods
function initialize(algObj, I, labelsToAutomate)
% disp(['Executing initialize on the first image frame at ' char(seconds(algObj.CurrentTime))])
%--------------------------------------------------------------
% Place your code here
%--------------------------------------------------------------
algObj.detector = yolov3ObjectDetector('darknet53-coco');
end
%
function autoLabels = run(algObj, I)
autoLabels = [];
%--------------------------------------------------------------
% Place your code here
%--------------------------------------------------------------
I = im2double(I);
[bboxes, scores, labels] = detect(algObj.detector,I);
idx = labels=='person';
personBox = bboxes(idx,:);
% personScores{i,1} = scores(idx);
personLabel = labels(idx);
if(~isempty(personLabel))
autoLabels.Name = algObj.SelectedLabelDefinitions.Name;
autoLabels.Position = personBox;
autoLabels.Type = labelType.Rectangle;
end
end
function terminate(algObj)
disp('Executing terminate')
end
end
end
Hope it will help!
Candice Earley
on 7 Oct 2021
Mahesh Taparia
on 8 Oct 2021
Can you share a screenshot of error?
Categories
Find more on Ground Truth Labeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!