-
Notifications
You must be signed in to change notification settings - Fork 0
/
pascal-voc-dataset-create.sh
executable file
·87 lines (60 loc) · 1.84 KB
/
pascal-voc-dataset-create.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Use: ./dataset-create-symlink.sh "path/to/dhaka-ai/Final Train Dataset" "path/to/copy/ImageSet/Main"
# This script creates a dataset made of symlinks in Pascal VOC structure.
# Train-Val-Test split is also created.
set -e
if [ $# -eq 0 ]
then
echo "Supply data dir path"
exit
fi
if [ -d datasets/voc/ ]; then
rm -r datasets/voc/
fi
mkdir -p datasets/voc/JPEGImages
mkdir -p datasets/voc/Annotations
mkdir -p datasets/voc/ImageSets/Main
for jpg in "$1"/*.jpg
do
ln -s "$jpg" datasets/voc/JPEGImages
done
for JPG in "$1"/*.JPG
do
ln -s "$JPG" datasets/voc/JPEGImages
done
for jpeg in "$1"/*.jpeg
do
ln -s "$jpeg" datasets/voc/JPEGImages
done
for png in "$1"/*.png
do
ln -s "$png" datasets/voc/JPEGImages
done
for PNG in "$1"/*.PNG
do
ln -s "$PNG" datasets/voc/JPEGImages
done
for xml in "$1"/*.xml
do
ln -s "$xml" datasets/voc/Annotations
done
python3 png2jpg.py datasets/voc/JPEGImages/ # Convert all png files to jpg
rename JPG jpg datasets/voc/JPEGImages/*.JPG || : # Convert uppercase file ext to lowercase
rename jpeg jpg datasets/voc/JPEGImages/*.jpeg || :
rename 's/\.JPG$/.jpg/' datasets/voc/JPEGImages/*.JPG || :
rename 's/\.jpeg$/.jpg/' datasets/voc/JPEGImages/*.jpeg || :
rm "datasets/voc/JPEGImages/231.jpg" # Corrupted file
rm "datasets/voc/Annotations/231.xml" # Corrupted file
rm "datasets/voc/Annotations/Pias (359).xml" # Corrupted file
rm "datasets/voc/JPEGImages/Pias (359).jpg" # Corrupted file
rm "datasets/voc/Annotations/Pias (360).xml" # Corrupted file
rm "datasets/voc/JPEGImages/Pias (360).jpg" # Corrupted file
if [ $2 = "generate" ]
then
python3 generateimagesets.py # Create train-test-val split in ImageSets dir
echo "Image Set Created"
else
cp -r datasets/ImageSets/Main/* datasets/voc/ImageSets/Main/
echo "Image Set Copied"
fi
echo "Done"