-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.sh
executable file
·98 lines (82 loc) · 2.28 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
check_pip3_dependency() {
if [ $( pip3 list | grep "$1" | wc -l ) -eq 0 ]; then
return 1
else
return 0
fi
}
check_system_dependency() {
if [ $( which $1 | wc -l ) -eq 0 ]; then
return 1
else
return 0
fi
}
check_lib_dependency() {
if [ $( dpkg-query -l "$1" | grep "$1" | wc -l ) -ne 1 ]; then
return 1
else
return 0
fi
}
check_ruby_dependency() {
if [ $( gem list | grep "$1" | wc -l ) -eq 0 ]; then
return 1
else
return 0
fi
}
check_darknet_installed() {
if [ -d "$SRC_DIR/bin/darknet" ]; then
return 0
else
return 1
fi
}
announce_success() {
echo "Success!"
echo " - Your DARKNET_DIR is: $SRC_DIR/bin/darknet"
echo " - Your TESSERACT_BIN_DIR is: $(dirname $(which tesseract))"
}
install_git() {
sudo apt-get install -y git
}
install_tesseract() {
sudo apt-get install -y tesseract-ocr
}
install_darknet() {
mkdir $SRC_DIR/bin
git clone https://github.com/alexcu/darknet.git bin/darknet
make -C bin/darknet
wget -P bin/darknet https://pjreddie.com/media/files/tiny-yolo-voc.weights
}
install_python3() {
sudo apt-get install -y python3-pip python3-dev
pip3 install --upgrade pip
}
install_python_libs() {
pip3 install -r requirements.txt
}
install_ruby() {
sudo apt-get install -y ruby ruby-all-dev
}
install_imagemagick() {
sudo apt-get install -y imagemagick libmagickcore-dev libmagickwand-dev
}
install_rmagick() {
sudo gem install rmagick
}
check_system_dependency "git" || install_git &&
check_system_dependency "tesseract" || install_tesseract &&
check_darknet_installed || install_darknet &&
check_system_dependency "python3" || install_python3 &&
check_system_dependency "pip3" || install_python3 &&
check_system_dependency "ruby" || install_ruby &&
check_system_dependency "convert" || install_imagemagick &&
check_lib_dependency "libmagickcore-dev" || install_imagemagick &&
check_lib_dependency "libmagickwand-dev" || install_imagemagick &&
check_ruby_dependency "rmagick" || install_rmagick &&
install_python_libs &&
announce_success