fix: make the YOLO weights path configurable and drop a dead import
Adds YOLO_MODEL_PATH (default unchanged) and bakes the weights into /tmp/Ultralytics in the image so a volume mounted over /app can't shadow them, plus removes the redundant top-level scenedetect import. Adapted from #47 by @kayceepeece, minus the CPU-only torch pin which would conflict with the GPU production build.
This commit is contained in:
parent
fea6364ffb
commit
8996ac9c1a
2 changed files with 8 additions and 4 deletions
|
|
@ -102,8 +102,11 @@ RUN chown -R appuser:appuser /app /tmp/Ultralytics
|
|||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
# Pre-download YOLO model on build (now running as appuser)
|
||||
RUN python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')"
|
||||
# Pre-download YOLO model on build (now running as appuser). Baked into
|
||||
# /tmp/Ultralytics instead of the workdir so a volume mounted over /app can't
|
||||
# shadow it and force a re-download at startup.
|
||||
ENV YOLO_MODEL_PATH=/tmp/Ultralytics/yolov8n.pt
|
||||
RUN python -c "from ultralytics import YOLO; YOLO('/tmp/Ultralytics/yolov8n.pt')"
|
||||
|
||||
# Expose FastAPI port
|
||||
EXPOSE 8000
|
||||
|
|
|
|||
5
main.py
5
main.py
|
|
@ -1,6 +1,5 @@
|
|||
import time
|
||||
import cv2
|
||||
import scenedetect
|
||||
import subprocess
|
||||
import argparse
|
||||
import re
|
||||
|
|
@ -79,7 +78,9 @@ OUTPUT — RETURN ONLY VALID JSON (no markdown, no comments). Order clips by pre
|
|||
"""
|
||||
|
||||
# Load the YOLO model once (Keep for backup or scene analysis if needed)
|
||||
model = YOLO('yolov8n.pt')
|
||||
# YOLO_MODEL_PATH lets deployments point at a pre-downloaded weights file so a
|
||||
# volume mounted over the workdir doesn't trigger a re-download at startup.
|
||||
model = YOLO(os.environ.get("YOLO_MODEL_PATH", "yolov8n.pt"))
|
||||
|
||||
# --- MediaPipe Setup ---
|
||||
# Use standard Face Detection (BlazeFace) for speed
|
||||
|
|
|
|||
Loading…
Reference in a new issue