This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
setup.sh
72 lines (60 loc) · 2.01 KB
/
setup.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
#!/bin/bash
WORKING_DIR=$(dirname "$(readlink -f "$0")")
echo "WORKING_DIR: ${WORKING_DIR}"
declare -a urls=(
"http://download.tensorflow.org/models/deeplabv3_mnv2_pascal_train_aug_2018_01_29.tar.gz"
"http://download.tensorflow.org/models/deeplabv3_pascal_train_aug_2018_01_04.tar.gz"
)
for url in ${urls[@]}; do
FILENAME=$(basename ${url})
FILE_PATH="${WORKING_DIR}/${FILENAME}"
if [[ ! -f "${FILE_PATH}" ]]; then
wget ${url}
fi
case ${FILENAME} in
"deeplabv3_mnv2_pascal_train_aug_2018_01_29.tar.gz" )
EXTRACT_PATH="${WORKING_DIR}/models/mobile_net_model/model"
;;
"deeplabv3_pascal_train_aug_2018_01_04.tar.gz")
EXTRACT_PATH="${WORKING_DIR}/models/xception_model/model"
;;
esac
if [[ ! -d "${EXTRACT_PATH}" ]]; then
mkdir -p ${EXTRACT_PATH}
fi
tar xvzf "${FILE_PATH}" -C ${EXTRACT_PATH} --strip=1
rm ${FILE_PATH}
done
PYTHON_PATH="$(which python3)"
SETUP_DIR="${WORKING_DIR}/setup/"
DOWNLOAD_SCRIPT_PY="${SETUP_DIR}/download.py"
# Install gdown if not installed, without this package globaly the installation will fail
${PYTHON_PATH} -m pip install gdown
if [[ -f ${DOWNLOAD_SCRIPT_PY} ]]; then
${PYTHON_PATH} ${DOWNLOAD_SCRIPT_PY}
else
echo "${DOWNLOAD_SCRIPT_PY}, not found!"
fi
declare -A files
files=(
["basnet.pth"]="/models/basnet/"
["u2net.pth"]="/models/u2net/"
["u2netp.pth"]="/models/u2netp/"
)
for file in ${!files[@]}; do
FILE_PATH="${WORKING_DIR}/${file}"
DESTINATION_DIR="${WORKING_DIR}/${files[${file}]}"
if [[ -f ${FILE_PATH} ]]; then
echo "Founded file: ${file}"
if [[ ! -d "${DESTINATION_DIR}" ]]; then
echo "Created dir: ${DESTINATION_DIR}"
mkdir -p "${DESTINATION_DIR}"
fi
if mv ${FILE_PATH} ${DESTINATION_DIR}; then
echo "${FILE_PATH} moved to ${DESTINATION_DIR}"
else
echo "Error while move file: ${FILE_PATH} to ${DESTINATION_DIR}"
fi
fi
done
rm -rf "${SETUP_DIR}"