当前位置:网站首页>为猪脸识别而进行自己数据集的构建、训练「建议收藏」
为猪脸识别而进行自己数据集的构建、训练「建议收藏」
2022-06-24 21:01:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
在实际过程中走了弯路,特地进行说明记录,以备今后参考。
思路是先构建VOC2007格式的猪脸数据集,在转换成tf格式,然后利用tf的objectdetectionapi进行训练。原因是把2种构建方式都熟悉一遍,并把所有流程过一遍。
1、构架VOC2007格式的猪脸数据集
前提:在某个目录下建立如下关系的子目录。
—— Annotations
—— ImageSets
—— Main
—— JPEGImages
第一步:准备自己需要的图片,最好是jpg格式。如若不是则需要转换成jpg格式。
因为很多图片都是从网上找的,格式、大小都不一样,为了后续训练需要最好统一下大小,并把格式统一转换成jpg格式。
图片的数量,一般来说最好一千张以上。为了后续训练出好的效果,最好一万张以上。
第二步:图片的重命名,因为VOC2007格式必须为JPG格式,并且图片是统一的六位数字,从000001开始。那我们也需要将所有训练图片重命名为此。
重命名后所有图片就可以拷贝到JPEGImages目录下。
第三步:进行目标物体的标注。推荐用labelImg,因为它可直接生成符合VOC2007格式的xml文件。
主要是体力活。
生成的所有xml文件就可以拷贝到Annotations目录下。
第四步:数据集的分割。
在实际训练过程中,需要四个文件,分别为test.txt是测试集,train.txt是训练集,val.txt是验证集,trainval.txt是训练和验证集。每个文件为对于图片的名字。在VOC2007中,trainval大概是整个数据集的50%,test也大概是整个数据集的50%;train大概是trainval的50%,val大概是trainval的50%。
参照python源码:split-datasets.py
生成的四个txt文件就可以拷贝到Main目录下。
第五步:如果上述各步骤中没有做拷贝的动作则在本步骤把相应的文件拷贝到对应的目录下。以符合VOC2007格式的要求。
—— Annotations 将xml文件全部放到该文件夹里
—— ImageSets
—— Main 其有四个txt文件,test.txt是测试集,train.txt是训练集,val.txt是验证集,trainval.txt是训练和验证集。Txt里的内容是即图片名字(无后缀)。
—— JPEGImages 所有的训练图片放到该文件夹里
第六步:把上述目录及其文件都拷贝到pigfaces/VOC2007/下。
第七步:转换成tf的record格式的数据集文件。
运行如下命令:cd 到xxx\object_detection目录下。python create_pascal_tf_record.py –data_dir=xxxx\object_detection\pigfaces –year=VOC2007 –set=train –output_path=data\pig_train.record
第八步:进行训练。
运行如下命令:cd 到xxx\objectdetection\object_detection目录下。python train.py –train_dir=data –pipeline_config_path=models\faster_rcnn_resnet101_voc07.config
上述的6,7,8可参考我的github代码,网址是https://github.com/renwoxing2016/Objectdetectionapi/。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151884.html原文链接:https://javaforall.cn
边栏推荐
- The optimism about technology is making Dell achieve more than expected
- 天书夜读笔记——8.4 diskperf反汇编
- AUTOCAD——两种延伸方式
- ImageView shows network pictures
- How to store dataframe data in pandas into MySQL
- Audio PCM data calculates sound decibel value to realize simple VAD function
- JVM directive
- 联想童夫尧:11倍于大势,我们一路攻城拔寨
- Deep learning LSTM model for stock analysis and prediction
- 启动服务11111
猜你喜欢
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
Tianshu night reading notes -- memory paging mechanism
Assembly language (3) 16 bit assembly basic framework and addition and subtraction loop
Ideas and examples of divide and conquer
Cobalt strike installation tutorial
Bi-sql - different join
Danish Technical University pioneered the application of quantum computing to power flow modeling of energy system
15.线程同步的几种方法
JVM directive
随机推荐
Cloud development technology summit · public welfare programming challenge [hot registration]!
vb学习什么[通俗易懂]
void* 指针
activity生命周期
ContentResolver,拿到手机短信内容
C language boundary calculation and asymmetric boundary
After the college entrance examination, the following four situations will inevitably occur:
期望与方差
音频PCM数据计算声音分贝值,实现简单VAD功能
修身励学篇
Convert MySQL query timestamp to date format
[practical series] full WiFi coverage at home
中金财富证券开户佣金多少呢?股票开户交易安全靠谱吗?
Super detailed description and derivation of convolution and deconvolution (deconvolution is also called transpose convolution and fractional step convolution)
"One good programmer is worth five ordinary programmers!"
梦想CAD云图与GIS结合演示
Bi-sql between
15. several methods of thread synchronization
VB learning notes
What to learn in VB [easy to understand]