Skip to content

fix: YOLO model path, Docker CPU optimization, remove dead import#47

Open
kayceepeece wants to merge 1 commit into
mutonby:mainfrom
kayceepeece:fix/vps-deployment-bugs
Open

fix: YOLO model path, Docker CPU optimization, remove dead import#47
kayceepeece wants to merge 1 commit into
mutonby:mainfrom
kayceepeece:fix/vps-deployment-bugs

Conversation

@kayceepeece

Copy link
Copy Markdown

Context

Deploying on a VPS (Docker) hits 3 bugs that prevent the app from running.

Changes

1. Make YOLO model path configurable (main.py + Dockerfile)

  • YOLO("yolov8n.pt") tries to download to CWD, but /app is volume-mounted in docker-compose, so the app user has no write permission → PermissionError
  • Add YOLO_MODEL_PATH env var (default: yolov8n.pt for bare-metal auto-download)
  • Docker sets /tmp/Ultralytics/yolov8n.pt (pre-downloaded during build, survives volume mount)
  • Bare-metal users get auto-download to CWD — no breakage

2. CPU-only PyTorch by default in Docker (Dockerfile)

  • Split pip install: torch via --index-url (explicit), rest via requirements.txt
  • TORCH_INDEX_URL build arg (default: https://download.pytorch.org/whl/cpu)
  • GPU users: docker compose build --build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu124
  • Image: 11.3 GB → 4.6 GB

This follows the same pattern as PyTorch own Dockerfile which uses ARG CUDA_PATH=cu121.

3. Remove unused import scenedetect (main.py)

Dead code after the open_video() refactor — no scenedetect. references remain.

Testing

  • docker compose build succeeds (4.6 GB image)
  • Backend starts and serves API on :8000
  • YOLO model loads from env-configured path
  • requirements.txt unchanged — bare-metal pip install still works

Copilot AI review requested due to automatic review settings June 24, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Docker/VPS deployment blockers by making the Ultralytics YOLO model location configurable, optimizing Docker builds for CPU-only PyTorch by default, and removing a dead import.

Changes:

  • Added YOLO_MODEL_PATH env support in main.py to control where the YOLO model is loaded from.
  • Updated Dockerfile to install CPU-only PyTorch via a configurable index URL and to pre-download the YOLO model into /tmp/Ultralytics.
  • Removed an unused import scenedetect from main.py.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
main.py Reads YOLO_MODEL_PATH from environment when instantiating the YOLO model; removes a redundant scenedetect import.
Dockerfile Adds CPU-only PyTorch installation flow and pre-downloads the YOLO model during build for Docker deployments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile Outdated
Comment on lines +23 to +25
# Point YOLO to pre-downloaded model (survives volume mount)
ENV YOLO_MODEL_PATH=/tmp/Ultralytics/yolov8n.pt

Comment thread Dockerfile Outdated
# GPU users: docker compose build --build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu124
ARG TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --index-url ${TORCH_INDEX_URL} torch torchvision
1. Make YOLO model path configurable via YOLO_MODEL_PATH env var
   - Default: yolov8n.pt (auto-downloads to CWD for bare-metal)
   - Docker: /tmp/Ultralytics/yolov8n.pt (pre-downloaded, survives volume mount)
   - Fixes PermissionError when docker-compose mounts .:/app

2. CPU-only PyTorch by default in Docker
   - Split pip install: torch via --index-url, rest via requirements.txt
   - TORCH_INDEX_URL build arg (default: cpu)
   - GPU users: --build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu124
   - Image: 11.3 GB → 4.6 GB

3. Remove unused import scenedetect (dead code after open_video refactor)
@kayceepeece kayceepeece force-pushed the fix/vps-deployment-bugs branch from 45c7c87 to f5b8a05 Compare June 24, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants