A vehicle detection and counting system that uses YOLO model to detect and count vehicles in videos.
Follow these simple steps to get the application up and running:
-
Clone this repository or extract the files to a directory
-
Navigate to the project directory:
cd your-project-directory -
Ensure the YOLO model file is present:
- The model file should be at
backend/yolo_model/yolo2.pt - If running the application for the first time, make sure this file exists
- The model file should be at
-
Start the application with Docker Compose:
docker-compose upFor a clean rebuild (recommended for first run):
docker-compose up --build -
Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- Health Check: http://localhost:8000/health
This Docker setup is configured to use the exact dependencies specified in:
frontend/package-lock.jsonfor the frontendbackend/requirements.txtfor the backend
The Docker configuration ensures that:
- No dependency updates occur during the build process
- The exact versions are maintained, eliminating "works on my machine" issues
- The containerized environment is identical to the development environment
- Upload a video file containing traffic.
- The application will process the video and count vehicles as they cross the counting line.
- Vehicle counts will be displayed in real-time.
To stop the application, press Ctrl+C in the terminal where docker-compose is running, or run:
docker-compose down
If you encounter any issues:
- Ensure Docker is running
- Check the Docker logs for any error messages:
docker-compose logs - Network issues: The application may need internet access for the first run. If you're behind a proxy or firewall, configure Docker's network settings accordingly.
- Try rebuilding the containers with no cache:
docker-compose build --no-cache docker-compose up - If the backend fails to start, check if the YOLO model file exists:
The file
ls -la backend/yolo_model/yolo2.ptshould be present in this directory. - If the frontend seems to be running but you can't access it, check if the port 5173 is already in use on your system.
If you see WebSocket connection errors:
-
Check that both services are running:
docker-compose ps -
Verify the backend health check:
curl http://localhost:8000/health -
Restart the containers:
docker-compose restart -
Check browser console for specific WebSocket errors
-
If problems persist, try running with host networking:
docker-compose down docker-compose -f docker-compose.yml -f docker-compose.host-network.yml up
- Missing YOLO Model: If you get an error about a missing model file, ensure the
yolo2.ptfile is located atbackend/yolo_model/yolo2.pt. - DNS Resolution: If the backend can't connect to the internet, the environment variable
ULTRALYTICS_SKIP_CHECK=1is set to avoid network checks. - Node.js memory issues: If the frontend build fails with memory errors, try increasing Docker's memory allocation in Docker Desktop settings.
- WebSocket connections: If you're having WebSocket connection issues, make sure no firewalls or proxies are blocking WebSocket traffic on port 8000.