一、制作数据
根据上篇内容来制作数据。
我用的是中草药的数据,包括三种药材;
cheqianzi:700张
JianLianHua:1000张
pugongying:500张
其中的百分之二十用于test,百分之八十用于train。
test:140+200+100=440张
train:560+800+400=1760张
文件存放如下:
在data/herbal_demo/下建立两个文件夹:
分别存放test和train图片。
二、制作数据
在examples/herbal_demo/下建立create_filelist.sh文件
内容如下:
#!/usr/bin/env sh
DATA=data/herbal/
MY=examples/herbal_demo
echo "Create train.txt..."
rm -rf $MY/train.txt
find $DATA/train -name cq2015*.jpg | cut -d '/' -f4-5 | sed "s/$/ 1/">>$MY/train.txt
find $DATA/train -name JLHZZ*.JPG | cut -d '/' -f4-5 | sed "s/$/ 2/">>$MY/train.txt
find $DATA/train -name py201512*.jpg | cut -d '/' -f4-5 | sed "s/$/ 3/">>$MY/train.txt
echo "Create test.txt..."
rm -rf $MY/test.txt
find $DATA/train -name cq2015*.jpg | cut -d '/' -f4-5 | sed "s/$/ 1/">>$MY/test.txt
find $DATA/train -name JLHZZ*.JPG | cut -d '/' -f4-5 | sed "s/$/ 2/">>$MY/test.txt
find $DATA/train -name py201512*.jpg | cut -d '/' -f4-5 | sed "s/$/ 3/">>$MY/test.txt
echo "All done"
$ ./examples/herbal_demo/create_filelist.sh
运行后:
生成test.txt和train.txt文件。
待续。。
本文介绍了一种中草药图像数据集的构建过程,包括数据收集、划分训练集和测试集,并通过Shell脚本自动生成训练和测试文件列表。
6万+

被折叠的 条评论
为什么被折叠?



