45 lines
1.3 KiB
Bash
45 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
DEMO="${ROOT}/PaddleOCR-VL-1.6_Online_Demo"
|
|
cd "$DEMO"
|
|
|
|
unset VIRTUAL_ENV
|
|
|
|
if [[ -f "${ROOT}/.env" ]]; then
|
|
set -a
|
|
# shellcheck disable=SC1091
|
|
source "${ROOT}/.env"
|
|
set +a
|
|
fi
|
|
|
|
PIPELINE_PORT="${PIPELINE_PORT:-8090}"
|
|
GRADIO_PORT="${GRADIO_PORT:-7870}"
|
|
export API_URL="${API_URL:-http://127.0.0.1:${PIPELINE_PORT}/layout-parsing}"
|
|
|
|
echo "==> Starting PaddleOCR-VL-1.6 Online Demo"
|
|
echo " API_URL: ${API_URL}"
|
|
echo " Gradio: http://127.0.0.1:${GRADIO_PORT}"
|
|
|
|
if command -v ss >/dev/null 2>&1 && ss -tln | grep -q ":${GRADIO_PORT} "; then
|
|
echo "ERROR: Port ${GRADIO_PORT} is already in use." >&2
|
|
echo " The demo may already be running — open http://127.0.0.1:${GRADIO_PORT}" >&2
|
|
echo " To restart: stop the old process (e.g. fuser -k ${GRADIO_PORT}/tcp) then run this script again." >&2
|
|
echo " Or use another port: GRADIO_PORT=7871 ./scripts/run-demo.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d .venv ]]; then
|
|
echo "==> Creating demo venv and installing requirements"
|
|
uv venv .venv --python 3.12
|
|
uv pip install --python .venv -r requirements.txt
|
|
fi
|
|
|
|
export GRADIO_SERVER_PORT="${GRADIO_PORT}"
|
|
export GRADIO_SERVER_NAME="127.0.0.1"
|
|
export GRADIO_MCP_SERVER="True"
|
|
|
|
exec uv run --no-project --python .venv/bin/python python app.py
|
|
|