-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_dataset.sh
More file actions
58 lines (41 loc) · 1.69 KB
/
get_dataset.sh
File metadata and controls
58 lines (41 loc) · 1.69 KB
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
dir="./dataset"
if [ ! -d "$dir" ]; then
echo "Downloading dataset, please wait until it finishes."
start=$(date +%s)
mkdir -p "$dir"
download_successful=0
attempt=1
max_attempts=10
while [ $download_successful -eq 0 ]; do
if [ $attempt -gt $max_attempts ]; then
echo "Unable to get dataset, servers are not responding, please try executing the 'get_dataset.sh' file at a couple of minutes or another time."
rm -rf "$dir"
exit 1
fi
echo "Trying to get dataset attempt $attempt/$max_attempts..."
curl -L -o "$dir"/open-sprayer-images.zip https://www.kaggle.com/api/v1/datasets/download/gavinarmstrong/open-sprayer-images
if [ $? -eq 0 ]; then
download_successful=1
else
echo "Connection error, retrying in 10 seconds..."
sleep 10
fi
attempt=$((attempt + 1))
done
total_files=$(unzip -Z1 "$dir"/open-sprayer-images.zip | grep -E "^(Docknet/train/|Docknet/valid/)" | wc -l)
echo "Unpacking files... ($total_files files total)"
counter=0
for file in $(unzip -Z1 "$dir"/open-sprayer-images.zip | grep -E "^(Docknet/train/|Docknet/valid/)"); do
unzip -q "$dir"/open-sprayer-images.zip "$file" -d "$dir"
counter=$((counter + 1))
stdbuf -o0 echo -ne "Unpacking files... ($counter/$total_files) files unpacked\r"
done
echo ""
rm "$dir"/open-sprayer-images.zip
rm -rf "$dir"/Docknet/Docknet
mv "$dir"/Docknet/* "$dir"
rm -rf "$dir"/Docknet
end=$(date +%s)
duration=$((end - start))
echo "Dataset downloaded and unpacked suscefully in $duration seconds."
fi