当前位置:网站首页>Build and train your own dataset for pig face recognition

Build and train your own dataset for pig face recognition

2022-06-25 01:55:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm your friend, Quan Jun .

I took a detour in the actual process , Make special notes , For future reference .

The idea is to build VOC2007 Format pig face data Set , It's converting to tf Format , And then use it tf Of objectdetectionapi Training . The reason is that 2 Be familiar with all the construction methods , And go through all the processes .

1、 The architecture VOC2007 Pig face dataset in

Premise : Create a subdirectory with the following relationship under a directory .

—— Annotations

—— ImageSets

—— Main

—— JPEGImages

First step : Prepare the pictures you need , It is best to jpg Format . If not, it needs to be converted to jpg Format .

Because many pictures are found on the Internet , Format 、 It's not the same size , It is better to unify the size for the follow-up training , And convert the format into jpg Format .

Number of pictures , Generally speaking, it is better to have more than 1000 pieces . In order to achieve good results in the follow-up training , It's better to have more than 10000 .

The second step : Rename the picture , because VOC2007 Format must be JPG Format , And the picture is a unified six digit number , from 000001 Start . Then we also need to rename all training images to this .

After renaming, all pictures can be copied to JPEGImages Under the table of contents .

The third step : Mark the target object . Recommend to use labelImg, Because it can directly generate data that conforms to VOC2007 Format xml file .

It's mainly physical work .

All generated xml Files can be copied to Annotations Under the table of contents .

Step four : Data set segmentation .

In the actual training process , Four files are required , Respectively test.txt It's a test set ,train.txt It's a training set ,val.txt It's a validation set ,trainval.txt It's a training and validation set . Each file has a name for the picture . stay VOC2007 in ,trainval About the whole data set 50%,test It's probably the of the whole data set 50%;train Probably trainval Of 50%,val Probably trainval Of 50%.

reference python Source code :split-datasets.py

Generated four txt Files can be copied to Main Under the table of contents .

Step five : If there is no copy action in the above steps, copy the corresponding files to the corresponding directory in this step . To conform to VOC2007 Format requirements .

—— Annotations take xml Put all the files in this folder

—— ImageSets

—— Main It has four txt file ,test.txt It's a test set ,train.txt It's a training set ,val.txt It's a validation set ,trainval.txt It's a training and validation set .Txt The content in is the name of the picture ( no suffix ).

—— JPEGImages Put all training pictures in this folder

Step six : Copy the above directories and their files to pigfaces/VOC2007/ Next .

Step seven : convert to tf Of record Data set file in the format .

Run the following command :cd To xxx\object_detection Under the table of contents .python create_pascal_tf_record.py –data_dir=xxxx\object_detection\pigfaces –year=VOC2007 –set=train –output_path=data\pig_train.record

Step eight : Training .

Run the following command :cd To xxx\objectdetection\object_detection Under the table of contents .python train.py –train_dir=data –pipeline_config_path=models\faster_rcnn_resnet101_voc07.config

Aforementioned 6,7,8 Please refer to my github Code , The address is https://github.com/renwoxing2016/Objectdetectionapi/.

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151884.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206242058576878.html