-
Notifications
You must be signed in to change notification settings - Fork 443
/
Copy pathcreate_list.sh
57 lines (51 loc) · 1.65 KB
/
create_list.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
root_dir=/media/data/
#root_dir="../../data/VOCdevkit"
sub_dir=ImageSets/Main
bash_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#for dataset in trainval test test_time_Afternoon test_time_Day test_time_Night test_weather_Cloudy test_weather_Normal test_weather_Rain
for dataset in train
do
dst_file=$bash_dir/$dataset.txt
if [ -f $dst_file ]
then
rm -f $dst_file
fi
for name in bdd100k #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
label_file2=$bash_dir/$dataset"_label2.txt"
cp $dataset_file $label_file2
sed -i "s/^/$name\/Annotations\//g" $label_file2
sed -i "s/$/_drivable_id.png/g" $label_file2
paste -d' ' $img_file $label_file $label_file2>> $dst_file
rm -f $label_file
rm -f $label_file2
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