create_list.sh 文件内容
注意使用之前请修改文件路径#!/bin/bash#注意使用之前请修改文件路径root_dir=/media/caffeusr/diska/data/VOCdevkitsub_dir=ImageSets/Main#bash_dir="/media/caffeusr/diska/caffe/data/VOC0712"bash_dir="$(cd "$(dirname "${BASH_SOURCE[0]
·
注意使用之前请修改文件路径
#!/bin/bash
#注意使用之前请修改文件路径
root_dir=/media/caffeusr/diska/data/VOCdevkit
sub_dir=ImageSets/Main
#bash_dir="/media/caffeusr/diska/caffe/data/VOC0712"
bash_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
for dataset in trainval test
do
dst_file=$bash_dir/$dataset.txt
if [ -f $dst_file ]
then
rm -f $dst_file
fi
for name in VOC2007 VOC2012
do
if [[ $dataset == "test" && $name == "VOC2012" ]]
then
continue
fi
echo "Create list for $name $dataset..."
dataset_file=$root_dir/$name/$sub_dir/$dataset.txt
img_file=$bash_dir/$dataset"_img.txt"
cp $dataset_file $img_file
sed -i "s/^/$name\/JPEGImages\//g" $img_file
sed -i "s/$/.jpg/g" $img_file
label_file=$bash_dir/$dataset"_label.txt"
cp $dataset_file $label_file
sed -i "s/^/$name\/Annotations\//g" $label_file
sed -i "s/$/.xml/g" $label_file
paste -d' ' $img_file $label_file >> $dst_file
rm -f $label_file
rm -f $img_file
done
# Generate image name and size infomation.
if [ $dataset == "test" ]
then
$bash_dir/../../build/tools/get_image_size $root_dir $dst_file $bash_dir/$dataset"_name_size.txt"
fi
# Shuffle trainval file.
if [ $dataset == "trainval" ]
then
rand_file=$dst_file.random
cat $dst_file | perl -MList::Util=shuffle -e 'print shuffle(<STDIN>);' > $rand_file
mv $rand_file $dst_file
fi
done
更多推荐
已为社区贡献3条内容
所有评论(0)