-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·69 lines (57 loc) · 2.64 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·69 lines (57 loc) · 2.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
#!/bin/bash
# ============================================================
# Setup script for PaddleOCR-VL-1.6 on Apple Silicon with UV
# ============================================================
set -e
echo "=== Setting up PaddleOCR-VL-1.6 environment with UV ==="
# Ensure UV is installed
if ! command -v uv &> /dev/null; then
echo "UV is not installed. Installing UV..."
curl -LsSf https://astral.sh/uv/install.sh | sh
# Reload shell environment
source "$HOME/.local/bin/env" 2>/dev/null || true
export PATH="$HOME/.cargo/bin:$PATH"
fi
echo "UV version: $(uv --version)"
# Remove old venv if it exists
rm -rf .venv
# Create virtual environment (Python 3.10-3.13 required by paddlepaddle)
echo "=== Creating virtual environment (Python 3.13) ==="
uv venv --python python3.13
echo "=== Installing PaddlePaddle (CPU version for Apple Silicon) ==="
uv pip install paddlepaddle==3.2.1 \
--index-url https://www.paddlepaddle.org.cn/packages/stable/cpu/ \
--index-strategy unsafe-best-match
echo "=== Installing PaddleOCR with doc-parser support ==="
uv pip install -U "paddleocr[doc-parser]"
echo "=== Installing Web/export dependencies (declared in pyproject.toml) ==="
# robyn/pillow/python-docx/PyMuPDF 集中在 pyproject.toml 声明, 由 uv 统一安装
uv pip install -r pyproject.toml
# Apple Silicon acceleration: MLX-VLM serves the VLM recognition model on the
# Apple GPU (much faster than local CPU inference). The web server auto-detects
# a running MLX-VLM server at http://localhost:8111/ and uses it automatically.
echo "=== Installing MLX-VLM (Apple Silicon GPU inference backend) ==="
uv pip install "mlx-vlm>=0.3.11" || \
echo "WARNING: mlx-vlm install failed; OCR will use local CPU inference"
# ModelScope SDK: downloads the MLX model from the China CDN (much faster
# and more reliable than a direct HuggingFace connection in CN networks)
echo "=== Installing ModelScope SDK (fast MLX model download) ==="
uv pip install "modelscope>=1.25" || \
echo "WARNING: modelscope install failed; start.sh will fall back to HF"
echo "=== Installing frontend dependencies with Bun ==="
cd web && bun install && bun run build && cd ..
echo ""
echo "=== Setup complete! ==="
echo ""
echo "To activate the environment:"
echo " source .venv/bin/activate"
echo ""
echo "To run the web server (auto-starts MLX-VLM if installed):"
echo " ./start.sh"
echo ""
echo "Or start components manually:"
echo " .venv/bin/python -m mlx_vlm.server --port 8111 --model ~/.cache/mlx_models/PaddlePaddle/PaddleOCR-VL-1.6 & # optional, GPU acceleration"
echo " .venv/bin/python server.py"
echo ""
echo "To build frontend assets:"
echo " cd web && bun run build"