cd data
mkdir -p mydata/MobileNet-SSD
cd mydata/MobileNet-SSD
mkdir Annotations ImageSets JPEGImages
cd ImageSets
mkdir Main
cd ../..cp../VOC0712/*.#coco_voc_map.txt用不着,只是为了省事,一起复制过来
cd ../../examples
mkdir mydata
#!/bin/bash# 第一处修改
root_dir=/home/lwd/code/dl/ssd/caffe/data/mydata
sub_dir=ImageSets/Main
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 MobileNet-SSD
doif[[$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_filerm-f $label_filerm-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_filemv$rand_file$dst_file
fi
done
修改create_data.sh如下
cur_dir=$(cd $( dirname ${BASH_SOURCE[0]}) && pwd)
root_dir=$cur_dir/../..
cd $root_dir
redo=1
# 第一处修改
data_root_dir="/home/lwd/code/dl/ssd/caffe/data/mydata"# 第二处修改
dataset_name="mydata"
mapfile="$root_dir/data/$dataset_name/labelmap_voc.prototxt"
anno_type="detection"
db="lmdb"
min_dim=0
max_dim=0
width=0
height=0
extra_cmd="--encode-type=jpg --encoded"if[$redo]
then
extra_cmd="$extra_cmd --redo"
fi
for subset in test trainval
do
python $root_dir/scripts/create_annoset.py --anno-type=$anno_type--label-map-file=$mapfile--min-dim=$min_dim--max-dim=$max_dim--resize-width=$width--resize-height=$height--check-label $extra_cmd$data_root_dir$root_dir/data/$dataset_name/$subset.txt $data_root_dir/$dataset_name/$db/$dataset_name"_"$subset"_"$db examples/$dataset_name
done