Vehicle-Counting / README.md
riezqidr's picture
Add initial project structure with Streamlit UI and utility functions
ab2f940
|
Raw
History Blame Contribute Delete
3.85 kB
---
title: Vehicle Detection Tracking Counting
emoji: "\U0001F697"
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: "1.28.0"
app_file: app.py
pinned: false
---
# Vehicle Detection, Tracking & Counting
Proyek portofolio AI Engineer untuk deteksi, tracking, dan penghitungan kendaraan secara otomatis dari video menggunakan **RT-DETR** sebagai model deteksi dan **ByteTrack** sebagai multi-object tracker.
## Fitur
- **Object Detection**: Deteksi kendaraan menggunakan RT-DETR yang sudah di-fine-tune pada dataset UA-DETRAC
- **Object Tracking**: Multi-object tracking dengan ByteTrack, setiap kendaraan mendapat ID unik
- **Vehicle Counting**: Dua metode counting tersedia:
- Virtual Line Counting: hitung kendaraan yang melewati garis virtual
- Polygon Region Counting: hitung kendaraan yang masuk area tertentu
- **Dashboard**: Statistik real-time, FPS, progress bar
- **Export**: Download video hasil dan CSV hasil counting
## Tech Stack
| Komponen | Teknologi |
|---|---|
| Object Detection | RT-DETR (Ultralytics) |
| Object Tracking | ByteTrack (custom implementation) |
| Video Processing | OpenCV |
| Web App | Streamlit |
| Deep Learning | PyTorch |
| Deployment | Hugging Face Spaces |
## Struktur Proyek
```
vehicle-counting-rtdetr/
β”œβ”€β”€ notebooks/
β”‚ └── kaggle_training.ipynb # Notebook training di Kaggle
β”œβ”€β”€ core/
β”‚ β”œβ”€β”€ detector.py # RT-DETR inference wrapper
β”‚ β”œβ”€β”€ tracker.py # ByteTrack implementation
β”‚ β”œβ”€β”€ counter.py # Virtual line & polygon counting
β”‚ └── exporter.py # CSV export utilities
β”œβ”€β”€ ui/
β”‚ └── sidebar.py # Streamlit sidebar components
β”œβ”€β”€ models/
β”‚ └── best.pt # Model hasil fine-tuning (dari Kaggle)
β”œβ”€β”€ outputs/ # Folder output video & CSV
β”œβ”€β”€ app.py # Main Streamlit application
β”œβ”€β”€ utils.py # Drawing & helper functions
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ packages.txt
└── README.md
```
## Setup
### Training (Kaggle)
1. Upload notebook `notebooks/kaggle_training.ipynb` ke Kaggle
2. Aktifkan GPU (P100 atau T4)
3. Jalankan semua cell
4. Download file `best.pt` dari output Kaggle
5. Letakkan `best.pt` di folder `models/`
### Local Development
```bash
# install dependencies
pip install -r requirements.txt
# jalankan app
streamlit run app.py
```
### Deploy ke Hugging Face Spaces
1. Buat repository baru di Hugging Face Spaces (pilih Streamlit SDK)
2. Upload semua file dari repository ini
3. Pastikan `best.pt` ada di folder `models/`
4. Spaces akan otomatis build dan deploy
## Cara Pakai
1. Buka aplikasi
2. Upload video (.mp4 / .avi) di sidebar
3. Atur confidence threshold
4. Pilih metode counting (Virtual Line atau Polygon Region)
5. Klik "Mulai Proses"
6. Tunggu sampai selesai
7. Download hasil video dan CSV
## Model Performance
Hasil evaluasi model RT-DETR setelah fine-tuning pada dataset kendaraan:
| Metric | Nilai |
|---|---|
| mAP50 | - |
| mAP50-95 | - |
| Precision | - |
| Recall | - |
| F1-Score | - |
*Tabel ini akan diupdate setelah training selesai di Kaggle.*
## Dataset
**UA-DETRAC Dataset 10K** dari Roboflow Universe:
- Link: https://universe.roboflow.com/rjacaac1/ua-detrac-dataset-10k
- Format: YOLOv8 (kompatibel dengan RT-DETR Ultralytics)
- Nama kelas dibaca otomatis dari `data.yaml` dataset
## Referensi
- [RT-DETR Paper](https://arxiv.org/abs/2304.08069) - DETRs Beat YOLOs on Real-time Object Detection
- [ByteTrack Paper](https://arxiv.org/abs/2110.06864) - Multi-Object Tracking by Associating Every Detection Box
- [Ultralytics](https://docs.ultralytics.com/) - YOLO & RT-DETR Framework
- [Roboflow](https://roboflow.com/) - Dataset Management
## License
MIT License