File size: 1,050 Bytes
42d4c60
 
 
 
3f24feb
 
 
42d4c60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
set -e

MODEL_PATH="/data/yolov11x_best.pt"
export SESSIONS_DIR="${SESSIONS_DIR:-/data/sessions}"
export PIPELINE_DIR="/app/pdf-script"
export YOLO_MODEL_PATH="/data/yolov11x_best.pt"

# Create sessions directory in persistent storage
mkdir -p "$SESSIONS_DIR"

# Download YOLO model from HF Hub on first boot
if [ ! -f "$MODEL_PATH" ]; then
    if [ -z "$HF_MODEL_REPO" ]; then
        echo "ERROR: HF_MODEL_REPO secret is not set. Cannot download YOLO model."
        echo "Set it to your HF model repo ID, e.g. yourname/pdf-pipeline-models"
        exit 1
    fi
    echo "Downloading YOLO model from HF Hub (first boot only)..."
    python -c "
from huggingface_hub import hf_hub_download
import os, shutil
path = hf_hub_download(
    repo_id=os.environ['HF_MODEL_REPO'],
    filename='yolov11x_best.pt',
    token=os.environ.get('HF_TOKEN'),
    local_dir='/data'
)
print(f'Model ready at {path}')
"
fi

echo "Starting FastAPI on port 7860..."
exec uvicorn main:app \
    --host 0.0.0.0 \
    --port 7860 \
    --app-dir /app/backend