当前位置:网站首页>Recognition of high-speed road signs by Matlab using alexnet

Recognition of high-speed road signs by Matlab using alexnet

2022-04-23 20:21:00 Install a sound 77

A classic case of transfer learning ,Alexnet It needs to be downloaded , Download requires registration matlab account number , Of course, this model is also available online , Make yourself at home .

doc Alexnet doc trainFasterRCNNObjectDetector

You can find the case information provided on the official website .

There are also relevant cases on the Internet for reference , Mainly refer to these two :

MATLAB2017a Use FasterRcnn Target detection training and its testing process _ Unknown little salted fish blog -CSDN Blog _matlab object detection

MATLAB2018b Train with your own data faster-RCNN Steps and error reporting solution _ It's Miss Jiang -CSDN Blog

Of course, the actual use will certainly have bug, It needs to be adjusted slowly .

Just pay attention to the overall format , Just go . It takes up more memory when running .

clc
clear all
load('alexnet.mat',"net")

image = imageDatastore('C:\Users\1\Desktop\matlab_test_net',...
'IncludeSubfolders',true,'LabelSource','foldernames');
layersTransfer=net.Layers(1:end-3);

numClasses = numel(categories(image.Labels));

layers = [

layersTransfer

fullyConnectedLayer(numClasses,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20)

softmaxLayer

classificationLayer];

options = trainingOptions('sgdm', ...
    'MiniBatchSize',5, ...
    'MaxEpochs',20, ...
    'InitialLearnRate',0.0001);
    

netTransfer = trainNetwork(image,layers,options)

  This is basically the default , Just change the photo storage path , Be careful img It's a photo format .

test= load('F:/xunlian/test.mat');     %it is not necessary
options = trainingOptions('sgdm', ...    
'InitialLearnRate', 1e-5, ...
'MaxEpochs', 20, ...                     %twenty times   The more training depth is not the better , It could backfire ,
'CheckpointPath', tempdir);
layer=netTransfer.Layers

% Here's the tsst incorrect , It should be a set of arrays , Is not a mat Count .
naq = readtable('test_table_youdian.xls')

% Use table  Combine the data , Instead of importing from the outside 

%naqq=table(test.gTruth.DataSource.Source,)
% For this naq To deal with 

file = [] ;
aaa = test.gTruth.LabelData.biaozhi;
for i =1:30
    file2=[file;test.gTruth.DataSource.Source{i}];
    %table2array(test.gTruth.LabelData(2,1))
    
end
file=naq.imageFilename;
naqqq=table(file,aaa)

This data type is mainly made into table type ,

There are two ways One is from mat Put the data in the file and table() Combine

There's another one readtable() read excel Data in , Depending on your personal situation, choose .

The data in this is actually , Path and cut point

Training takes some time ( Add a key point , Need to add one backgroud Folder , Because this model is essentially a classification model , At least two categories are required, that is, there are two data sets , If you encounter this error , Refer to the previous blog )

  And then I put this detector Save as mat Format

Then comes the test

img=imread(" picture .jpg")
load('wangluo.mat')
[bbox,score,label] = detect(detector,img);
index = find(score>0.8);
bbox = bbox(index,:);
score = score(index,:);
label = label(index,:);
img = insertObjectAnnotation(img,'Rectangle',bbox,score);
img = insertShape(img,'Rectangle',bbox);
imshow(img)

The test image is shown below :

It's rough , But the good thing is that it's simple , convenient , fast ......

Just make do with it , Don't think about publishing a paper . 

版权声明
本文为[Install a sound 77]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210551491110.html