OccluSense AI - Advanced Occlusion-Aware Object Detection System for Autonomous Vehicles Using YOLOv8 and Custom NMS Algorithms
Back to ProjectFollow these comprehensive step-by-step instructions to set up and run the OccluSense AI project on your local machine.
Extract the downloaded project ZIP file to your desired location. Navigate to the extracted folder:
cd "Occlusion aware Object Detection for SelfDriving Cars"
Note: If you cloned from Git, use: git clone [repository-url]
Creating a virtual environment isolates project dependencies from your system Python installation:
python -m venv venv
Why Virtual Environment? It prevents dependency conflicts and keeps your system Python clean.
Activate the virtual environment based on your operating system:
venv\Scripts\activate
source venv/bin/activate
Success Indicator: You should see (venv) prefix in your command prompt.
Install all required Python packages using the requirements file:
pip install -r requirements.txt
This will install the following major packages:
Installation Time: This may take 5-10 minutes depending on your internet speed.
The YOLOv8 pre-trained model weights will be automatically downloaded on first run. However, you can manually download them:
python -c "from ultralytics import YOLO; model = YOLO('yolov8n.pt')"
Available model sizes:
Default Model: The project uses yolov8n.pt for optimal speed-accuracy balance.
Set up the SQLite database schema by running migrations:
python manage.py makemigrations detection
python manage.py migrate
This creates the following database tables:
Create an admin account to access the Django admin panel:
python manage.py createsuperuser
You will be prompted to enter:
Admin Panel URL: Access at http://127.0.0.1:8000/admin/
Ensure media directories exist for file uploads and results:
mkdir -p media/uploads media/results
For Windows:
mkdir media\uploads media\results
Start the Django development server:
python manage.py runserver
You should see output similar to:
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Custom Port: To run on a different port, use python manage.py runserver 8080
Open your web browser and navigate to:
You can customize detection parameters in occlusion_detection/settings.py:
DETECTION_CONFIG = {
'MODEL_PATH': 'yolov8n.pt', # YOLOv8 model variant
'DEFAULT_CONFIDENCE_THRESHOLD': 0.25, # Minimum confidence score
'DEFAULT_IOU_THRESHOLD': 0.45, # IoU threshold for NMS
'DEFAULT_NMS_METHOD': 'standard', # NMS method (standard/soft/diou)
'SOFT_NMS_SIGMA': 0.5, # Sigma for Soft-NMS
'TARGET_CLASSES': [0, 1, 2, 3, 5, 7, 9], # COCO class IDs to detect
}
| Class ID | Class Name | Description |
|---|---|---|
| 0 | person | Pedestrians, cyclists |
| 1 | bicycle | Bicycles on road |
| 2 | car | Cars and sedans |
| 3 | motorcycle | Motorcycles and scooters |
| 5 | bus | Buses |
| 7 | truck | Trucks and lorries |
| 9 | traffic light | Traffic signals |
For real-time webcam detection feature:
# Check if webcam is detected
ls /dev/video*
# Install v4l-utils if needed
sudo apt-get install v4l-utils
# Test webcam
v4l2-ctl --list-devices
The application provides RESTful API endpoints for programmatic access:
curl -X POST -F "file=@image.jpg" \
-F "nms_method=soft" \
-F "confidence_threshold=0.25" \
-F "iou_threshold=0.45" \
http://127.0.0.1:8000/api/detect/
curl http://127.0.0.1:8000/api/results/1/
curl -X POST -F "file=@image.jpg" \
http://127.0.0.1:8000/api/compare-nms/
curl http://127.0.0.1:8000/api/metrics/
For deploying to production environment:
# In settings.py
DEBUG = False
ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com']
# Use PostgreSQL instead of SQLite
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'occlusense_db',
'USER': 'your_db_user',
'PASSWORD': 'your_db_password',
'HOST': 'localhost',
'PORT': '5432',
}
}
python manage.py collectstatic
pip install gunicorn
# Run with Gunicorn
gunicorn occlusion_detection.wsgi:application --bind 0.0.0.0:8000
# Install Nginx
sudo apt-get install nginx
# Configure Nginx
sudo nano /etc/nginx/sites-available/occlusense
# Add configuration
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static/ {
alias /path/to/static/;
}
location /media/ {
alias /path/to/media/;
}
}
Error: ModuleNotFoundError: No module named 'django'
Solution: Ensure virtual environment is activated and dependencies are installed:
# Activate venv first
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Then install
pip install -r requirements.txt
Error: Error: That port is already in use.
Solution: Use a different port or kill the process:
# Use different port
python manage.py runserver 8080
# Or kill existing process (Linux/Mac)
lsof -ti:8000 | xargs kill -9
# Windows
netstat -ano | findstr :8000
taskkill /PID [process_id] /F
Error: RuntimeError: CUDA out of memory
Solution: Switch to CPU or use smaller model:
# In settings.py, set:
DETECTION_CONFIG = {
'MODEL_PATH': 'yolov8n.pt', # Use nano model
'DEVICE': 'cpu', # Force CPU usage
}
Solution:
Error: Unable to download model weights
Solution: Manually download and place in project root:
# Download from:
# https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt
# Place in project root directory
mv ~/Downloads/yolov8n.pt /path/to/project/
Error: PermissionError: [Errno 13] Permission denied: 'media/uploads'
Solution: Set proper permissions:
# Linux/Mac
chmod -R 755 media/
# Windows - Run as Administrator
icacls media /grant Everyone:F /T
Verify everything is working correctly:
http://127.0.0.1:8000/upload/http://127.0.0.1:8000/compare/# Test API endpoint
curl -X POST -F "file=@test_image.jpg" \
-F "nms_method=standard" \
http://127.0.0.1:8000/api/detect/
# Should return JSON with detection results
http://127.0.0.1:8000/webcam/DEVICE='cuda' in settings for 5-10x faster processingIf you encounter any issues during installation or usage:
Our team is here to assist you with installation and setup.