why my training yolov2 network can't work?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I trained my data set according to the official documentation, detecting people in the image, only one category. The pre-training network also uses resnet50. The network structure is consistent with the example, but after many trainings, people are still not detected. During this time I tried to use the clustering algorithm to change the size or number of the achor box, the value of MaxEpochs, but still not working. Why is this?
I post my code and data here:
%% 利用resnet50预训练网络进行特征提取
load('gTruthPerson.mat')
% Define the image input size.
ImageWeight = 320;
ImageHeight = 320;
imageSize = [ImageWeight ImageHeight 3];
% Define the number of object classes to detect.
numClasses = 1;
anchorBoxes = [
176 67
150 52
113 42
271 99
99 34
]; % .*ImageWeight/1280
anchorBoxes = round(anchorBoxes);
baseNetwork = resnet50();
% Specify the feature extraction layer.
featureLayer = 'activation_40_relu'; % mobilenetv2 的是'global_average_pooling2d_1';
% Create the YOLO v2 object detection network.
lgraph = yolov2Layers(imageSize,numClasses,anchorBoxes,baseNetwork,featureLayer);
doTraining=0;
if doTraining
% Configure the training options.
% * Lower the learning rate to 1e-3 to stabilize training.
% * Set CheckpointPath to save detector checkpoints to a temporary
% location. If training is interrupted due to a system failure or
% power outage, you can resume training from the saved checkpoint.
options = trainingOptions('sgdm', ...
'MiniBatchSize', 24, ....
'InitialLearnRate',1e-3, ...
'MaxEpochs',20,...
'Verbose',1, ...
'VerboseFrequency',1,...
'CheckpointPath', './save', ...
'ExecutionEnvironment','gpu',...
'Shuffle','every-epoch');
% Train YOLO v2 detector.
% pretrained = load('save/yolov2_checkpoint__45__2019_08_02__16_44_13.mat');
% detector = pretrained.detector;
[detector,info] = trainYOLOv2ObjectDetector(gTruthPerson,lgraph,options);
save yoloDetector.mat detector info
else
% Load pretrained detector for the example.
pretrained = load('yoloDetector.mat');
detector = pretrained.detector;
info = pretrained.info;
end
%% test
for i = 1:height(gTruthPerson)
I = imread(gTruthPerson.imageFilename{i});
% I = imresize(I,imageSize(1:2));
% Run the detector.
[bboxes,scores] = detect(detector,I);
% Annotate detections in the image.
if ~isempty(bboxes)
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
imshow(I)
end
end
all images and annotation files is here: google drive
0 Kommentare
Antworten (1)
Siehe auch
Kategorien
Mehr zu Recognition, Object Detection, and Semantic Segmentation 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!