-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.sh
More file actions
202 lines (163 loc) · 8.64 KB
/
install.sh
File metadata and controls
202 lines (163 loc) · 8.64 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/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"
# Fix for lxml build failures on aarch64 when installing PaddleOCR dependencies.
# lxml>=5/6 may be built from source if no wheel is available on the mirror.
# Ensure system headers exist so a source build can succeed, and preinstall a
# compatible binary lxml for Python 3.8 to avoid building from source.
installAptPackages "libxml2-dev libxslt1-dev zlib1g-dev pkg-config"
if [ "$oneStepPIP" = false ]; then
installPythonPackagesByName "Cython six requests wheel pyyaml"
# Prefer a prebuilt wheel for Python 3.8 to avoid source builds on aarch64 mirrors.
if [ "${pythonVersion}" = "3.8" ]; then
installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)"
fi
else
# When doing one-step pip, still try to mitigate lxml builds for Py3.8
if [ "${pythonVersion}" = "3.8" ]; then
installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)"
fi
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
# Ensure system headers for lxml in case a source build is needed by PaddleOCR deps
write "Ensuring system headers for lxml are present..." $color_info
sudo apt-get update -y >/dev/null 2>/dev/null
installAptPackages "libxml2-dev libxslt1-dev zlib1g-dev pkg-config"
writeLine "Done" $color_success
# For Python 3.8 on Jetson, preinstall a binary lxml to avoid building from source on aarch64
if [ "${pythonVersion}" = "3.8" ]; then
installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)"
fi
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
# Preinstall lxml to avoid source builds on macOS if PaddleOCR pulls it in
if [ "${pythonVersion}" = "3.8" ]; then
installPythonPackagesByName "lxml==4.9.4" "lxml XML/HTML parser (preinstalled to avoid source build)"
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