why my training yolov2 network can't work?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!