-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
136 lines (107 loc) · 5.37 KB
/
install.sh
File metadata and controls
136 lines (107 loc) · 5.37 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
#!/bin/bash
# Development mode setup script ::::::::::::::::::::::::::::::::::::::::::::::
#
# OCR
#
# This script is called from the OCR directory using:
#
# bash ../../CodeProject.AI-Server/src/setup.sh
#
# The setup.sh script 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 [ "${edgeDevice}" = "Raspberry Pi" ] || [ "${edgeDevice}" = "Orange Pi" ] ||
[ "${edgeDevice}" = "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, and this needs to be installed first
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"
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 [ "${edgeDevice}" = "Jetson" ]; then
moduleInstallErrors="Unable to install PaddleOCR on Jetson."
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
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 [ "$arcbhitecture" == "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