57 lines
1.5 KiB
Bash
57 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
MODEL_DIR=${MINERU_MODEL_DIR:-/models}
|
|
PIPELINE_MODEL_DIR=${MINERU_PIPELINE_MODEL_DIR:-${MODEL_DIR}/pipeline}
|
|
VLM_MODEL_DIR=${MINERU_VLM_MODEL_DIR:-${MODEL_DIR}/vlm}
|
|
CONFIG_PATH=${MINERU_TOOLS_CONFIG_JSON:-/root/mineru.json}
|
|
|
|
mkdir -p "$(dirname "$CONFIG_PATH")"
|
|
|
|
export CONFIG_PATH PIPELINE_MODEL_DIR VLM_MODEL_DIR
|
|
|
|
if [ ! -f "$CONFIG_PATH" ]; then
|
|
python3 - <<'PY'
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
config_path = Path(os.environ["CONFIG_PATH"])
|
|
config = {
|
|
"bucket_info": {"[default]": [None, None, None]},
|
|
"latex-delimiter-config": {
|
|
"display": {"left": "$$", "right": "$$"},
|
|
"inline": {"left": "$", "right": "$"},
|
|
},
|
|
"llm-aided-config": {
|
|
"title_aided": {
|
|
"api_key": "",
|
|
"base_url": "",
|
|
"model": "",
|
|
"enable_thinking": False,
|
|
"enable": False,
|
|
}
|
|
},
|
|
"models-dir": {
|
|
"pipeline": os.environ["PIPELINE_MODEL_DIR"],
|
|
"vlm": os.environ["VLM_MODEL_DIR"],
|
|
},
|
|
"config_version": "1.3.1",
|
|
}
|
|
config_path.write_text(json.dumps(config, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
PY
|
|
fi
|
|
|
|
export MINERU_TOOLS_CONFIG_JSON="$CONFIG_PATH"
|
|
export MINERU_MODEL_SOURCE=${MINERU_MODEL_SOURCE:-local}
|
|
export PYTHONPATH=${PYTHONPATH:-/app}
|
|
|
|
# Keep the historical Docker command while passing deployment-only settings
|
|
# through the wrapper instead of patching the official MinerU kernel.
|
|
if [ "${1:-}" = "mineru-api" ]; then
|
|
shift
|
|
set -- python3 /app/scripts/run_parser.py "$@"
|
|
fi
|
|
|
|
exec "$@"
|