-
大小: 5KB文件类型: .m金币: 1下载: 0 次发布日期: 2021-06-03
- 语言: Matlab
- 标签:
资源简介
这个m文件需要添加相应的图片数据集,只要数据集足够大,可以实现对任一物体的识别。
代码片段和文件信息
clear all;
isReSplitSamples = 0;
numTrainSam = 20;
numTestSam = 0;
nRounds = 10;
fvFeaturesFlag = 3; %1-just use only one gmmComponent for all feature maps.
%0-use one gmmComponent for each features map that is the length of gmmComp will be 512 in our experiment
%2-regard N(ie.512) feature maps as N dinmension of a patch which is slide in result matrix.
%3-regard N(ie.512) feature maps as N dimension of a patch which is slide in result matrix.
%In each patch connect each pixel‘s Ndimension features that for one patch it has N * patchW * patchH dimension feature
fvNormFlag = 1; %1-do normalization in fv 0 - do not
nGMM = 64;
fvSlideWindow.sizePatch = 3;
fvSlideWindow.step = 1;
rationSamGMM = 1;
modelName = ‘imagenet-vgg-m‘;
layerSelected = ‘conv5‘;
dataSet = [modelName‘__‘layerSelected];
%for numTrainSam = [510204080]
resultDir = [‘..\result\‘dataSet‘\resultRecord\‘];
samSplitPath = [‘..\result\‘dataSet‘\sampleSplitted-‘num2str(numTrainSam)‘tr\‘];
if ~isdir(resultDir)
mkdir(resultDir);
end
if ~isdir(samSplitPath)
mkdir(samSplitPath);
end
dDataSelectedPrePorcForExpPath = ‘..\dataPrePorcess\‘;
dDataSelectedPrePorcForExpPath = [dDataSelectedPrePorcForExpPathmodelName‘__‘layerSelected‘\‘];
libVlfeatPath = ‘..\tool\VLFEAT\vlfeat-0.9.19\toolbox\‘;
liblinearPath = ‘..\tool\liblinear\matlab\‘;
libsvmPath = ‘..\tool\libsvm\matlab\‘;
addpath(liblinearPath);
addpath(libsvmPath);
addpath(libVlfeatPath);
vl_setup;
load([dDataSelectedPrePorcForExpPath‘samples.mat‘]‘samplesAll‘‘samplesAllLabel‘);
samplesAllLabel = samplesAllLabel‘;
accuracyAll = zeros(nRounds 1);
%predLabelAll = cell(nRounds 1);
%gndLabelAll = cell(nRounds 1);
for ii = 1:nRounds
disp([‘***** Round ‘num2str(ii)‘ :‘]);
if isReSplitSamples
disp(‘***** Splitting the samples to training samples and testing samples...‘);
[samplesTrainsamplesTestsamplesTrainIndexInAllsamplesTestIndexInAll] = funSplitSamNew(samplesAllsamplesAllLabelnumTrainSamnumTestSam);
save([samSplitPath‘round_‘num2str(ii)‘_Splitted.mat‘]‘samplesTrain‘‘samplesTest‘‘samplesTrainIndexInAll‘‘samplesTestIndexInAll‘);
else
disp(‘***** Loading the training samples and testing samples preslplitted already...‘);
load([samSplitPath‘round_‘num2str(ii)‘_Splitted.mat‘]‘samplesTrain‘‘samplesTest‘‘samplesTrainIndexInAll‘‘samplesTestInd
评论
共有 条评论