AI-Powered Parking Management & Occupancy Detection System
SmartPark AI is a production-ready computer vision system that performs real-time vehicle detection and parking slot occupancy analysis using state-of-the-art YOLO models. Built with a professional Streamlit dashboard, it delivers enterprise-grade parking analytics with an intuitive web interface.
| Feature | Description |
|---|---|
| π€ YOLO Detection | Vehicle detection using YOLOv8/v11 (cars, motorcycles, buses, trucks) |
| Polygon-based parking slot management with configurable layouts | |
| π Real-time Analytics | Live occupancy metrics, vehicle distribution, and trend analysis |
| π Interactive Charts | Plotly-powered visualizations for occupancy trends and statistics |
| π₯ Video Processing | Annotated video export with bounding boxes and occupancy status |
| π CSV Reporting | Automated timestamped reports with full occupancy history |
| π§ CPU-Optimized | Efficient processing optimized for laptop/desktop deployment |
| π Web Dashboard | Modern Streamlit interface with drag-and-drop video upload |
| Category | Technologies |
|---|---|
| Deep Learning | Ultralytics YOLOv8/v11 |
| Computer Vision | OpenCV, Supervision |
| Web Framework | Streamlit |
| Visualization | Plotly |
| Data Processing | NumPy, Pandas |
| OCR (Optional) | EasyOCR |
| Language | Python 3.8+ |
SmartPark AI/
βββ π src/
β βββ app.py # Streamlit web application
β βββ utils.py # Core detection & parking utilities
β βββ demo.py # Standalone CLI demo script
βββ π data/
β βββ parking_slots.json # Sample parking slot configuration
βββ π models/ # Downloaded YOLO models (auto-created)
βββ π outputs/ # Annotated videos & CSV reports
βββ π samples/ # Sample videos for testing
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Python 3.8 or higher
- 4GB+ RAM (8GB recommended)
- Webcam or video file for testing
-
Clone the repository
git clone https://github.com/shubham333k/SmartPark-AI.git cd SmartPark-AI -
Create virtual environment
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Download YOLO model (automatic on first run)
# Or manually download to models/ directory: # - yolov8n.pt (fastest) # - yolov8s.pt (balanced) # - yolo11n.pt (latest)
Launch the Streamlit dashboard:
streamlit run src/app.pyThe app will open in your browser at http://localhost:8501
Workflow:
- Configure YOLO model and confidence threshold in sidebar
- Upload a parking lot video (MP4, AVI, MOV)
- Preview and confirm auto-generated parking slots
- Click "Start Processing" to analyze the video
- View real-time occupancy metrics and charts
- Download annotated video and CSV report
For quick testing without the web interface:
# Auto-generate slots and process video
python src/demo.py --video samples/parking_lot.mp4 --save
# Use custom slot configuration
python src/demo.py --video samples/parking_lot.mp4 --slots data/parking_slots.json --model yolov8s.ptOption 1: Auto-Grid (Default)
- Automatically generates rectangular slots in a grid pattern
- Configure rows/columns via the sidebar
Option 2: Custom JSON Create a JSON file defining polygon coordinates:
{
"slots": [
{
"slot_id": 1,
"polygon": [
[100, 200], [250, 200], [250, 280], [100, 280]
]
}
]
}| Model | Speed | Accuracy | Use Case |
|---|---|---|---|
yolov8n.pt |
β‘ Fastest | Good | Real-time processing |
yolov8s.pt |
π Fast | Better | Balanced performance |
yolo11n.pt |
β‘ Fast | Best | Latest architecture |
Tested on CPU (Intel i5-1240P / AMD Ryzen 5):
| Resolution | Model | FPS | Accuracy* |
|---|---|---|---|
| 640x480 | YOLOv8n | 25-30 | 85% |
| 1280x720 | YOLOv8n | 15-20 | 88% |
| 1280x720 | YOLOv8s | 10-15 | 91% |
| 1920x1080 | YOLOv8n | 8-12 | 87% |
*Accuracy = Occupancy detection accuracy with 0.3 overlap threshold
Main interface showing video upload, slot configuration, and processing controls
Live occupancy metrics with progress indicators and vehicle distribution
Plotly charts showing occupancy rate over time with threshold indicators
Processed video with green (vacant) and red (occupied) slot indicators
Timestamped occupancy data with vehicle counts and violations
# Optional: Set model download directory
export SMARTPARK_MODEL_DIR="./models"
# Optional: Disable EasyOCR for faster processing
export SMARTPARK_DISABLE_OCR="1"Modify DetectionConfig in src/utils.py to detect different vehicle types:
vehicle_classes: List[int] = [2, 3, 5, 7] # COCO: car, motorcycle, bus, truck
class_names: Dict[int, str] = {
2: "Car",
3: "Motorcycle",
5: "Bus",
7: "Truck"
}Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ultralytics for YOLO models
- Streamlit for the amazing web framework
- Supervision for computer vision utilities
- Plotly for interactive visualizations
AI/ML Engineer
π© shubhamjhanjhot333k@gmail.com
π LinkedIn
π SmartPark AI - Intelligent Parking for Smart Cities ποΈ
Built with β€οΈ using Python, YOLO, and Streamlit
