为对象检测器创建培训数据
[
从指定的地面真理创建图像数据存储和框标签数据存储培训数据。IMDS.
那BLDS.
] = ObjectDettortRainingData(gTruth
)
您可以使用组合图像和框标签数据存储结合
(IMDS.
那BLDS.
)创建培训所需的数据存储。使用培训函数的组合数据存储,如trainACFObjectDetector
那Trainyolov2ObjectDetector.
那trainfastrcnnobjectdetector.
那trainFasterRCNNObjectDetector
, 和trainrcnnobjectdetector.
。
此功能支持使用多个MATLA万博1manbetxB的并行计算®工人。使用parally计算使用计算机视觉工具箱首选项对话。
___= ObjectDettortRainingData(
返回一个培训数据表,其中包含一个或多个名称值对参数指定的其他选项。如果你创造了gTruth
那名称,价值
)地面
对象gTruth
使用视频文件,自定义数据源或imageageAtastore.
具有不同自定义读取功能的对象,然后您可以指定名称值对参数的任何组合。如果你创造了地面
来自图像集合或图像序列数据源的对象,然后您只能指定“SamplingFactor.
'名称-值对参数。
基于YOLO V2网络列车车辆探测器。
将包含图像的文件夹添加到工作区。
imagedir = fullfile(matlabroot,'工具箱'那'想象'那“visiondata”那'车辆');AddPath(Imagedir);
加载车辆地面真理数据。
data = load(“vehicleTrainingGroundTruth.mat”);gtruth = data.vehicletraingdroundtruth;
加载包含图层图对象进行培训的探测器。
vevicledetector = load('yolov2vehicledetectormat'mat');Lgraph =车辆levedector.lgraph.lgraph.
LAPHAGH =具有属性的分层图:图层:[25×1 nnet.cnn.layer.layer]连接:[24×2表]输入名称:{'输入'} OutputNames:{'yolov2outputlayer'}
使用地面真实对象创建图像数据存储和框标签数据存储。
[IMDS,BXDS] = ObjectDettortRainingData(GTRUTH);
组合数据存储。
cd =结合(imd, bxds);
配置培训选项。
选项=培训选项('sgdm'那......'italllearnrate',0.001,......'verbose',真的,......“MiniBatchSize”, 16岁,......'maxepochs',30,......“洗牌”那'每个时代'那......'verbosefrequency',10);
训练探测器。
[探测器,信息] = trainyolov2ObjectDetector(CD,LGraph,选项);
************************************************************************* 培训YOLO v2意思对象探测器以下对象类:*车辆培训单CPU。|========================================================================================| | 时代| |迭代时间| Mini-batch | Mini-batch |基地学习 | | | | ( hh: mm: ss) | RMSE | |率损失 | |========================================================================================| | 1 | 1 |就是| 7.50 | 56.2 | 0.0010 | | 1 |10 | 00:00:02 | 1.73 | 3.0 | 0.0010 | | 2 | 20 | 00:00:04 | 1.58 | 2.5 | 0.0010 | | 2 | 30 | 00:00:06 | 1.36 | 1.9 | 0.0010 | | 3 | 40 | 00:00:08 | 1.13 | 1.3 | 0.0010 | | 3 | 50 | 00:00:09 | 1.01 | 1.0 | 0.0010 | | 4 | 60 | 00:00:11 | 0.95 | 0.9 | 0.0010 | | 4 | 70 | 00:00:13 | 0.84 | 0.7 | 0.0010 | | 5 | 80 | 00:00:15 | 0.84 | 0.7 | 0.0010 | | 5 | 90 | 00:00:17 | 0.70 | 0.5 | 0.0010 | | 6 | 100 | 00:00:19 | 0.65 | 0.4 | 0.0010 | | 7 | 110 | 00:00:21 | 0.73 | 0.5 | 0.0010 | | 7 | 120 | 00:00:23 | 0.60 | 0.4 | 0.0010 | | 8 | 130 | 00:00:24 | 0.63 | 0.4 | 0.0010 | | 8 | 140 | 00:00:26 | 0.64 | 0.4 | 0.0010 | | 9 | 150 | 00:00:28 | 0.57 | 0.3 | 0.0010 | | 9 | 160 | 00:00:30 | 0.54 | 0.3 | 0.0010 | | 10 | 170 | 00:00:32 | 0.52 | 0.3 | 0.0010 | | 10 | 180 | 00:00:33 | 0.45 | 0.2 | 0.0010 | | 11 | 190 | 00:00:35 | 0.55 | 0.3 | 0.0010 | | 12 | 200 | 00:00:37 | 0.56 | 0.3 | 0.0010 | | 12 | 210 | 00:00:39 | 0.55 | 0.3 | 0.0010 | | 13 | 220 | 00:00:41 | 0.52 | 0.3 | 0.0010 | | 13 | 230 | 00:00:42 | 0.53 | 0.3 | 0.0010 | | 14 | 240 | 00:00:44 | 0.58 | 0.3 | 0.0010 | | 14 | 250 | 00:00:46 | 0.47 | 0.2 | 0.0010 | | 15 | 260 | 00:00:48 | 0.49 | 0.2 | 0.0010 | | 15 | 270 | 00:00:50 | 0.44 | 0.2 | 0.0010 | | 16 | 280 | 00:00:52 | 0.45 | 0.2 | 0.0010 | | 17 | 290 | 00:00:54 | 0.47 | 0.2 | 0.0010 | | 17 | 300 | 00:00:55 | 0.43 | 0.2 | 0.0010 | | 18 | 310 | 00:00:57 | 0.44 | 0.2 | 0.0010 | | 18 | 320 | 00:00:59 | 0.44 | 0.2 | 0.0010 | | 19 | 330 | 00:01:01 | 0.38 | 0.1 | 0.0010 | | 19 | 340 | 00:01:03 | 0.41 | 0.2 | 0.0010 | | 20 | 350 | 00:01:04 | 0.39 | 0.2 | 0.0010 | | 20 | 360 | 00:01:06 | 0.42 | 0.2 | 0.0010 | | 21 | 370 | 00:01:08 | 0.42 | 0.2 | 0.0010 | | 22 | 380 | 00:01:10 | 0.39 | 0.2 | 0.0010 | | 22 | 390 | 00:01:12 | 0.37 | 0.1 | 0.0010 | | 23 | 400 | 00:01:13 | 0.37 | 0.1 | 0.0010 | | 23 | 410 | 00:01:15 | 0.35 | 0.1 | 0.0010 | | 24 | 420 | 00:01:17 | 0.29 | 8.3e-02 | 0.0010 | | 24 | 430 | 00:01:19 | 0.36 | 0.1 | 0.0010 | | 25 | 440 | 00:01:21 | 0.28 | 7.9e-02 | 0.0010 | | 25 | 450 | 00:01:22 | 0.29 | 8.1e-02 | 0.0010 | | 26 | 460 | 00:01:24 | 0.28 | 8.0e-02 | 0.0010 | | 27 | 470 | 00:01:26 | 0.27 | 7.1e-02 | 0.0010 | | 27 | 480 | 00:01:28 | 0.25 | 6.3e-02 | 0.0010 | | 28 | 490 | 00:01:30 | 0.24 | 5.9e-02 | 0.0010 | | 28 | 500 | 00:01:31 | 0.29 | 8.4e-02 | 0.0010 | | 29 | 510 | 00:01:33 | 0.35 | 0.1 | 0.0010 | | 29 | 520 | 00:01:35 | 0.31 | 9.3e-02 | 0.0010 | | 30 | 530 | 00:01:37 | 0.18 | 3.1e-02 | 0.0010 | | 30 | 540 | 00:01:38 | 0.22 | 4.6e-02 | 0.0010 | |========================================================================================| Detector training complete. *************************************************************************
读取测试图像。
我= imread ('detectcars.png');
运行探测器。
[bboxes,scores] =检测(探测器,i);
显示结果。
如果(〜isempty(bboxes))i = InsertObjectAnnotation(I,'矩形'bboxes,分数);结尾图imshow(i)
使用培训数据培训基于ACF的对象探测器以进行停止标志
将包含图像的文件夹添加到MATLAB路径。
imagedir = fullfile(matlabroot,'工具箱'那'想象'那“visiondata”那'stopsignimages');AddPath(Imagedir);
负载地面真理数据,其中包含停止标志和汽车的数据。
加载('stopsignsandcarsgroundtruth.mat'那'stopsignsandcarsgardtruth')
查看标签定义以查看地面真相中的标签类型。
stopSignsAndCarsGroundTruth。LabelDefinitions
ans =.3×3表名称类型组____________ __________ ________ {'stopsign'}矩形{'none'} {'carrear'} rectangle {'none'} {'carfront'} rectangle {'none'}
选择停止标志数据进行培训。
stopSignGroundTruth = selectLabelsByName (stopSignsAndCarsGroundTruth,'停止标志');
创建停止标志对象检测器的培训数据。
trainingdata = ObjectDettortRainingData(STOPSIGNGRINDTRUTH);摘要(TrainingData)
变量:ImageFileName:41x1字符向量阵列停止:41x1单元格
培训基于ACF的物体探测器。
acfdetector = trainacfobjectdetector(trainingdata,'否定amplefactor',2);
ACF对象探测器培训培训将需要4个阶段。模型尺寸为34x31。样本阳性例子(〜100%完成)计算近似系数......完成。计算聚合信道功能...已完成。---------------------------------------------第1阶段:样本否定例子(〜100%完成)计算聚合信道功能...完成。火车分类器有42个正面例子和84个否定例子......完成。训练有素的分类器有19名弱者。------------------------------------------第2阶段:样本否定例子(〜100%完成)发现了84个培训的新负例。计算聚合信道功能...已完成。火车分类器有42个正面例子和84个否定例子......完成。 The trained classifier has 20 weak learners. -------------------------------------------- Stage 3: Sample negative examples(~100% Completed) Found 84 new negative examples for training. Compute aggregated channel features...Completed. Train classifier with 42 positive examples and 84 negative examples...Completed. The trained classifier has 54 weak learners. -------------------------------------------- Stage 4: Sample negative examples(~100% Completed) Found 84 new negative examples for training. Compute aggregated channel features...Completed. Train classifier with 42 positive examples and 84 negative examples...Completed. The trained classifier has 61 weak learners. -------------------------------------------- ACF object detector training is completed. Elapsed time is 28.6919 seconds.
在样本图像上测试基于ACF的探测器。
我= imread (“stopSignTest.jpg”);Bboxes =检测(Acfdetector,i);
显示检测到的对象。
annotation = acfdetector.modelname;i = InsertObjectAnnotation(i,'矩形',bboxes,注释);图imshow(i)
从路径中移除图像文件夹。
rmpath(imagedir);
使用培训数据培训基于ACF的物体探测器。
imagedir = fullfile(matlabroot,'工具箱'那'驾驶'那'divertdata'那'车辆不等);AddPath(Imagedir);
加载地面真理数据。
加载Warthegroundtruth.Mat
为车辆创建对象检测器的培训数据。
trainingdata = ObjectDettortRainingData(GTRUTH,'samplingfactor',2);
培训基于ACF的物体探测器。
acfdetector = trainacfobjectdetector(trainingdata,'objectTrainingsize',[20 20]);
ACF对象探测器培训培训将需要4个阶段。模型尺寸为20x20。样本阳性例子(〜100%完成)计算近似系数......完成。计算聚合信道功能...已完成。---------------------------------------------第1阶段:样本否定例子(〜100%完成)计算聚合信道功能...完成。火车分类器有71个正面例子和355个否定例子......完成。训练有素的分类器有68名弱势学习者。------------------------------------------第2阶段:样本否定例子(〜100%完成)发现了76个培训的新负面例子。计算聚合信道功能...已完成。火车分类器有71个正面例子和355个否定例子......完成。 The trained classifier has 120 weak learners. -------------------------------------------- Stage 3: Sample negative examples(~100% Completed) Found 54 new negative examples for training. Compute aggregated channel features...Completed. Train classifier with 71 positive examples and 355 negative examples...Completed. The trained classifier has 170 weak learners. -------------------------------------------- Stage 4: Sample negative examples(~100% Completed) Found 63 new negative examples for training. Compute aggregated channel features...Completed. Train classifier with 71 positive examples and 355 negative examples...Completed. The trained classifier has 215 weak learners. -------------------------------------------- ACF object detector training is completed. Elapsed time is 11.5031 seconds.
在测试图像上测试ACF检测器。
我= imread ('highway.png');[Bboxes,scores] =检测(Acfdetector,我,“阈值”,1);
选择最高分类分数的检测。
[〜,idx] = max(得分);
显示检测到的对象。
annotation = acfdetector.modelname;i = InsertObjectAnnotation(i,'矩形',bboxes(idx,:),注释);图imshow(i)
从路径中移除图像文件夹。
rmpath(imagedir);
gTruth
-地面真理数据地面
对象地面真理数据,指定为标量或数组地面
对象。您可以通过使用通过现有地面真实数据创建地面真实对象地面
目的。
如果您使用自定义数据源地面
启用并行计算,然后读取器功能预计将使用Matlab Worker池,以并行地从数据源读取图像。
指定可选的逗号分离对名称,价值
论点。名称
是参数名称和价值
是相应的价值。名称
必须出现在引号内。您可以以任何顺序指定多个名称和值对参数name1,value1,...,namen,valuen
。
'samplingfactor'
那5.
'samplingfactor'
-用于限制图像的因素'汽车'
(默认)|整数|整数矢量在地面真实数据源中的分离图像的因素,指定为'汽车'
,整数或整数矢量。用于抽样因子N,返回的培训数据包括每个N在地面真理数据源中的图像。该函数忽略带空标签数据的地面真理图像。
价值 | 抽样系数 |
---|---|
'汽车' |
采样系数N是5. 对于带时间戳的数据源,和1 对于一系列图像。 |
整数 | 所有地面真理数据源gTruth 采用相同的采样系数进行采样N。 |
整数矢量 | 这K.Th Rimite Tract数据源gTruth 采用抽样因子进行采样N(K.)。 |
“NamePrefix”
-输出图像文件名的前缀输出图像文件名的前缀,指定为字符串标量或字符向量。图像文件命名为:
< name_prefix > < source_number > _ < image_number >。< image_format >
默认值使用从中提取图像的数据源的名称,Strcat(Sourcename,'_')
,用于视频和自定义数据源,或'数据存储'
,对于图像数据存储。
此参数仅适用于:
地面
使用视频文件或自定义数据源创建的对象。
一系列地面
使用的对象imageageAtastore.
用不同的习俗读
功能。
该函数忽略此参数何时:
'verbose'
-旗帜显示培训进度真的
(默认)|错误的
标志显示Matlab命令行的培训进度,指定为真的
要么错误的
。此属性仅适用于地面
使用视频文件或自定义数据源创建的对象。
IMDS.
- 图像数据存储imageageAtastore.
目的图像数据存储,作为一个返回imageageAtastore.
包含从中提取图像的对象gTruth
对象。图像in.IMDS.
包含至少一类注释的标签。该功能忽略未注释的图像。
BLDS.
- 框标签数据存储boxlabeldatastore.
目的框标签数据存储,作为一个返回boxlabeldatastore.
目的。数据存储区包含ROI标签名称的分类向量m- 4个矩阵m边界框。边界框的位置和尺寸表示为双倍m-by-4元素矢量格式[X那y那宽度那高度]。
extimateanchorboxes.
|trainACFObjectDetector
|trainFasterRCNNObjectDetector
|trainfastrcnnobjectdetector.
|trainrcnnobjectdetector.
|Trainyolov2ObjectDetector.
您单击了与此MATLAB命令对应的链接:
通过在MATLAB命令窗口中输入命令来运行命令。Web浏览器不支持MATLAB命令。万博1manbetx
您还可以从以下列表中选择一个网站:
选择中国网站(以中文或英文)以获取最佳网站性能。其他MathWorks国家网站未优化您的位置。