-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.sh
More file actions
171 lines (136 loc) · 6.94 KB
/
install.sh
File metadata and controls
171 lines (136 loc) · 6.94 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# Installation script ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#
# ALPR
#
# This script is called from the ALPR directory using:
#
# bash ../../CodeProject.AI-Server/src/setup.sh
#
# The setup.sh file will find this install.sh file and execute it.
#
# For help with install scripts, notes on variables and methods available, tips,
# and explanations, see /src/modules/install_script_help.md
if [ "$1" != "install" ]; then
echo
read -t 3 -p "This script is only called from: bash ../../CodeProject.AI-Server/src/setup.sh"
echo
exit 1
fi
if [ "${systemName}" = "Raspberry Pi" ] || [ "${systemName}" = "Orange Pi" ] || \
[ "${systemName}" = "Radxa ROCK" ]; then
oneStepPIP=false
if [ "$oneStepPIP" = false ]; then
installPythonPackagesByName "numpy==1.23.3 protobuf<=3.20"
fi
# PaddleOCR 2.7.0.3 requires OpenCV 4.6.0.66
installPythonPackagesByName "opencv-python==4.6.0.66" "OpenCV, the Computer Vision library for Python"
# a fresh start
write "Updating apt-get..."
sudo apt-get update -y >/dev/null 2>/dev/null
sudo apt-get upgrade -y >/dev/null 2>/dev/null
writeLine "Done" "$color_success"
# install dependencies
installAptPackages "cmake"
installAptPackages "libatlas-base-dev libopenblas-dev libblas-dev"
installAptPackages "liblapack-dev patchelf gfortran"
if [ "$oneStepPIP" = false ]; then
installPythonPackagesByName "Cython six requests wheel pyyaml"
fi
"$venvPythonCmdPath" -m pip show paddlepaddle >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
writeLine "PaddlePaddle already installed" "$color_success"
else
# download the wheel
wheel_file="paddlepaddle-2.4.2-cp39-cp39-linux_aarch64.whl"
# wheel_file="paddlepaddle-2.5.1-cp310-cp310-linux_aarch64.whl"
if [ ! -f "${downloadDirPath}/${platform_dir}/packages/${wheel_file}" ]; then
wget -P "${downloadDirPath}/${platform_dir}/packages/" https://github.com/Qengineering/Paddle-Raspberry-Pi/raw/main/${wheel_file}
fi
# install Paddle
installPythonPackagesByName "${downloadDirPath}/${platform_dir}/packages/${wheel_file}" "PaddlePaddle"
fi
# clean up
# rm "${downloadDirPath}/${platform_dir}/packages/${wheel_file}"
# moduleInstallErrors= ...
elif [ "${systemName}" = "Jetson" ]; then
case "$pythonVersion" in
"3.6")
wheel_file="paddlepaddle_gpu-2.4.1-cp36-cp36m-linux_aarch64.whl"
wheel_path="https://paddle-inference-lib.bj.bcebos.com/2.4.1/python/Jetson/jetpack4.5_gcc7.5/all/" ;;
"3.7")
wheel_file="paddlepaddle_gpu-2.4.1-cp37-cp37m-linux_aarch64.whl"
wheel_path="https://paddle-inference-lib.bj.bcebos.com/2.4.1/python/Jetson/jetpack4.6.1_gcc7.5/all/" ;;
"3.8")
wheel_file="paddlepaddle_gpu-2.4.1-cp38-cp38-linux_aarch64.whl"
wheel_path="https://paddle-inference-lib.bj.bcebos.com/2.4.1/python/Jetson/jetpack5.0.2_gcc9.4/all/" ;;
*)
wheel_file="paddlepaddle_gpu-2.4.1-cp36-cp36m-linux_aarch64.whl"
wheel_path="https://paddle-inference-lib.bj.bcebos.com/2.4.1/python/Jetson/jetpack4.5_gcc7.5/all/" ;;
esac
"$venvPythonCmdPath" -m pip show paddlepaddle >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
writeLine "PaddlePaddle already installed" "$color_success"
else
# download the wheel
if [ ! -f "${downloadDirPath}/${platform_dir}/packages/${wheel_file}" ]; then
wget -P "${downloadDirPath}/${platform_dir}/packages/" ${wheel_path}${wheel_file}
fi
# install Paddle
installPythonPackagesByName "${downloadDirPath}/${platform_dir}/packages/${wheel_file}" "PaddlePaddle"
fi
# clean up
# rm "${downloadDirPath}/${platform_dir}/packages/${wheel_file}"
fi
# libssl.so.1.1: cannot open shared object file: No such file or directory
# https://github.com/PaddlePaddle/Paddle/issues/55597
if [ "${moduleInstallErrors}" = "" ] && [ "$os" = "linux" ] && [ "$architecture" == "x86_64" ]; then
if [ ! -f /usr/lib/x86_64-linux-gnu/libssl.so.1.1 ] || [ ! -e /usr/lib/libcrypto.so.1.1 ]; then
# output a warning message if no admin rights and instruct user on manual steps
install_instructions="cd ${moduleDirPath}${newline}sudo bash ../../CodeProject.AI-Server/src/setup.sh"
checkForAdminAndWarn "$install_instructions"
if [ "$isAdmin" = true ] || [ "$attemptSudoWithoutAdminRights" = true ]; then
moduleInstallErrors=""
if [ "$os_name" != "debian" ]; then
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
fi
installAptPackages "libssl1.1"
write "Ensuring symlinks are created..." $color_info
# LIBSSL: Add link at /usr/lib/libssl.so.1.1 that points to /lib/x86_64-linux-gnu/libssl.so.1.1
if [ -f /lib/x86_64-linux-gnu/libssl.so.1.1 ] && [ ! -e /usr/lib/libssl.so.1.1 ]; then
if [ "${verbosity}" = "loud" ]; then
sudo ln -s /lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/libssl.so.1.1
else
sudo ln -s /lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/libssl.so.1.1 >/dev/null 2>/dev/null
fi
fi
# LIBRYPTO: Add link at /usr/lib/libcrypto.so.1.1 that points to /lib/x86_64-linux-gnu/libcrypto.so.1.1
if [ -f /lib/x86_64-linux-gnu/libcrypto.so.1.1 ] && [ ! -e /usr/lib/libcrypto.so.1.1 ]; then
if [ "${verbosity}" = "loud" ]; then
sudo ln -s /lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
else
sudo ln -s /lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1 >/dev/null 2>/dev/null
fi
fi
writeLine "Done" $color_success
fi
fi
fi
if [ "$os" = "macos" ]; then
# The Numpy Debacle, 2024
installPythonPackagesByName "numpy==1.23.3" "NumPy, a package for scientific computing"
if [ "$os_name" = "Big Sur" ]; then # macOS 11.x on Intel, kernal 20.x
# https://github.com/opencv/opencv-python/issues/777
installPythonPackagesByName "opencv-python==4.6.0.66" "OpenCV 4.8, the Computer Vision library for Python"
elif [ "$architecture" == "arm64" ]; then
installPythonPackagesByName "opencv-python==4.5.5.64" "OpenCV 4.5, the Computer Vision library for Python"
else
installPythonPackagesByName "opencv-python" "OpenCV, the Computer Vision library for Python"
fi
fi
if [ "${moduleInstallErrors}" = "" ]; then
# Download the OCR models and store in /paddleocr
getFromServer "models/" "ocr-en-pp_ocrv4-paddle.zip" "paddleocr" "Downloading OCR models..."
# TODO: Check paddleocr created and has files, maybe run paddle check too
# moduleInstallErrors=...
fi