fix: YOLO model path, Docker CPU optimization, remove dead import#47
Open
kayceepeece wants to merge 1 commit into
Open
fix: YOLO model path, Docker CPU optimization, remove dead import#47kayceepeece wants to merge 1 commit into
kayceepeece wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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_PATHenv support inmain.pyto control where the YOLO model is loaded from. - Updated
Dockerfileto install CPU-only PyTorch via a configurable index URL and to pre-download the YOLO model into/tmp/Ultralytics. - Removed an unused
import scenedetectfrommain.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 on lines
+23
to
+25
| # Point YOLO to pre-downloaded model (survives volume mount) | ||
| ENV YOLO_MODEL_PATH=/tmp/Ultralytics/yolov8n.pt | ||
|
|
| # 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)
45c7c87 to
f5b8a05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/appis volume-mounted in docker-compose, so the app user has no write permission →PermissionErrorYOLO_MODEL_PATHenv var (default:yolov8n.ptfor bare-metal auto-download)/tmp/Ultralytics/yolov8n.pt(pre-downloaded during build, survives volume mount)2. CPU-only PyTorch by default in Docker (Dockerfile)
torchvia--index-url(explicit), rest viarequirements.txtTORCH_INDEX_URLbuild arg (default:https://download.pytorch.org/whl/cpu)docker compose build --build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu124This 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 — noscenedetect.references remain.Testing
docker compose buildsucceeds (4.6 GB image)requirements.txtunchanged — bare-metalpip installstill works