Files
secondary-school-grade-archive/deploy/ocr-worker/install.sh
T

46 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 在带 NVIDIA 显卡(如 RTX 3060 Ti)的 Linux 机器上安装 OCR Worker
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
VENV="${ROOT}/.venv"
PORT="${OCR_PORT:-23567}"
echo "==> OCR Worker 安装目录: ${ROOT}"
if ! command -v python3 >/dev/null; then
echo "请先安装 python3"
exit 1
fi
python3 -m venv "${VENV}"
# shellcheck disable=SC1091
source "${VENV}/bin/activate"
pip install -U pip wheel
# Paddle GPUCUDA 11.8,适配多数 3060 Ti 驱动)
pip install paddlepaddle-gpu==2.6.2 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
pip install -r "${ROOT}/requirements.txt"
cat <<EOF
安装完成。
启动(前台测试):
cd ${ROOT}
OCR_USE_GPU=true OCR_PORT=${PORT} bash start.sh
局域网地址示例:
http://192.168.x.x:${PORT}
在成绩档案「系统设置 → AI 模型」里填写 OCR 服务地址:
http://192.168.x.x:${PORT}
可选环境变量:
OCR_USE_GPU=true # 使用显卡(默认 true)
OCR_API_KEY=随机字符串 # 局域网鉴权(可选)
OCR_MAX_SIDE=1280 # 识别长边上限
OCR_PORT=${PORT} # 监听端口
EOF