Object Detection
ultralytics
computer-vision
yolov8
vehicle-detection
traffic-analysis
highway-monitoring
Instructions to use vietnguyennn0705/highway-vehicle-detection-code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use vietnguyennn0705/highway-vehicle-detection-code with ultralytics:
from ultralytics import YOLOvv8 model = YOLOvv8.from_pretrained("vietnguyennn0705/highway-vehicle-detection-code") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
Nguyễn Quốc Việt commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,208 +1,208 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
tags:
|
| 4 |
-
- computer-vision
|
| 5 |
-
- object-detection
|
| 6 |
-
- yolov8
|
| 7 |
-
- vehicle-detection
|
| 8 |
-
- traffic-analysis
|
| 9 |
-
- highway-monitoring
|
| 10 |
-
library_name: ultralytics
|
| 11 |
-
pipeline_tag: object-detection
|
| 12 |
-
---
|
| 13 |
-
|
| 14 |
-
# Highway Vehicle Detection - Code & Models
|
| 15 |
-
|
| 16 |
-
A complete vehicle detection system for highway traffic monitoring. This repository contains the trained models, source code, and documentation - ready to use without requiring dataset downloads.
|
| 17 |
-
|
| 18 |
-
## Quick Start
|
| 19 |
-
|
| 20 |
-
### Installation
|
| 21 |
-
```bash
|
| 22 |
-
pip install ultralytics opencv-python numpy
|
| 23 |
-
```
|
| 24 |
-
|
| 25 |
-
### Basic Usage
|
| 26 |
-
```python
|
| 27 |
-
from ultralytics import YOLO
|
| 28 |
-
|
| 29 |
-
# Load the trained model
|
| 30 |
-
model = YOLO('models/yolov8m_stage2_improved_best.pt')
|
| 31 |
-
|
| 32 |
-
# Run inference on an image
|
| 33 |
-
results = model('path/to/image.jpg')
|
| 34 |
-
results[0].show()
|
| 35 |
-
|
| 36 |
-
# Process video
|
| 37 |
-
results = model('path/to/video.mp4', save=True)
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
### Using the Main Application
|
| 41 |
-
```bash
|
| 42 |
-
python main.py
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
## Repository Contents
|
| 46 |
-
|
| 47 |
-
### Trained Models
|
| 48 |
-
- `models/yolov8m_stage2_improved_best.pt` - **Final model** (recommended)
|
| 49 |
-
- `models/yolov8m_stage1_smart_best.pt` - Stage 1 model (for comparison)
|
| 50 |
-
|
| 51 |
-
### Source Code
|
| 52 |
-
- `main.py` - Complete vehicle detection and counting application
|
| 53 |
-
- `example_usage.py` - Simple usage examples
|
| 54 |
-
- `requirements.txt` - Python dependencies
|
| 55 |
-
- `test_improved_model.bat` - Windows testing script
|
| 56 |
-
|
| 57 |
-
### Fine-tuning Dataset
|
| 58 |
-
- `finetune_dataset/images/` - 92 fine-tuning images
|
| 59 |
-
- `finetune_dataset/labels/` - Corresponding annotation files
|
| 60 |
-
- `finetune_dataset/README.dataset.txt` - Dataset information
|
| 61 |
-
- `finetune_dataset/README.roboflow.txt` - Roboflow export info
|
| 62 |
-
|
| 63 |
-
### Configuration
|
| 64 |
-
- `dataset_configs/main_data.yaml` - Main dataset configuration (8 classes)
|
| 65 |
-
- `dataset_configs/finetune_data.yaml` - Fine-tuning dataset configuration
|
| 66 |
-
|
| 67 |
-
### Training Logs
|
| 68 |
-
- `training_logs/stage2_results.png` - Training results visualization
|
| 69 |
-
- `training_logs/stage2_confusion_matrix.png` - Confusion matrix
|
| 70 |
-
- `training_logs/stage2_results.csv` - Detailed training metrics
|
| 71 |
-
- `training_logs/stage2_val_batch0_pred.jpg` - Sample validation predictions
|
| 72 |
-
|
| 73 |
-
### Training Runs Structure
|
| 74 |
-
- `training_runs/stage1_smart/` - Stage 1 training configuration and weights
|
| 75 |
-
- `args.yaml` - Training arguments
|
| 76 |
-
- `weights/last.pt` - Last epoch weights
|
| 77 |
-
- `training_runs/stage2_improved/` - Stage 2 training configuration and weights
|
| 78 |
-
- `args.yaml` - Training arguments
|
| 79 |
-
- `weights/last.pt` - Last epoch weights
|
| 80 |
-
- `BoxF1_curve.png` - F1 score curve
|
| 81 |
-
- `BoxPR_curve.png` - Precision-Recall curve
|
| 82 |
-
- `labels.jpg` - Label distribution visualization
|
| 83 |
-
|
| 84 |
-
### Documentation
|
| 85 |
-
- `PROJECT_REPORT.md` - Complete project documentation
|
| 86 |
-
- `README.md` - This file
|
| 87 |
-
|
| 88 |
-
## Model Performance
|
| 89 |
-
|
| 90 |
-
### Classes Detected
|
| 91 |
-
1. **auto** - Three-wheelers
|
| 92 |
-
2. **bus** - Public transport vehicles
|
| 93 |
-
3. **car** - Passenger cars
|
| 94 |
-
4. **lcv** - Light Commercial Vehicles
|
| 95 |
-
5. **motorcycle** - Two-wheelers
|
| 96 |
-
6. **multiaxle** - Multi-axle heavy vehicles
|
| 97 |
-
7. **tractor** - Agricultural/construction vehicles
|
| 98 |
-
8. **truck** - Heavy vehicles
|
| 99 |
-
|
| 100 |
-
### Training Stages
|
| 101 |
-
- **Stage 1**: Initial training on 8,219 highway images
|
| 102 |
-
- **Stage 2**: Fine-tuning on 92 additional images for improved truck/bus detection
|
| 103 |
-
|
| 104 |
-
### Fine-tuning Dataset Details
|
| 105 |
-
- **Images**: 92 carefully selected highway images
|
| 106 |
-
- **Focus**: Improved detection of trucks and buses
|
| 107 |
-
- **Classes**: Enhanced examples for problematic vehicle types
|
| 108 |
-
- **Format**: YOLO format with bounding box annotations
|
| 109 |
-
- **Quality**: High-quality images with clear vehicle visibility
|
| 110 |
-
|
| 111 |
-
## External Resources
|
| 112 |
-
|
| 113 |
-
### Test Video
|
| 114 |
-
Watch the model in action on YouTube:
|
| 115 |
-
[Highway Vehicle Detection Demo](https://www.youtube.com/watch?v=wqctLW0Hb_0&list=PLJKyZ_NuOhJQzif2-6-Kq9OiOj_UjJWvi)
|
| 116 |
-
|
| 117 |
-
### Main Dataset
|
| 118 |
-
Download the complete training dataset from Kaggle:
|
| 119 |
-
[Vehicle Detection 8 Classes Dataset](https://www.kaggle.com/datasets/sakshamjn/vehicle-detection-8-classes-object-detection/data)
|
| 120 |
-
|
| 121 |
-
## Technical Details
|
| 122 |
-
|
| 123 |
-
- **Architecture**: YOLOv8m (Medium)
|
| 124 |
-
- **Framework**: Ultralytics YOLO
|
| 125 |
-
- **Input**: Images/Videos
|
| 126 |
-
- **Output**: Bounding boxes with class labels and confidence scores
|
| 127 |
-
- **Hardware**: CPU/GPU compatible
|
| 128 |
-
|
| 129 |
-
## Usage Examples
|
| 130 |
-
|
| 131 |
-
### Vehicle Detection
|
| 132 |
-
```python
|
| 133 |
-
from ultralytics import YOLO
|
| 134 |
-
import cv2
|
| 135 |
-
|
| 136 |
-
# Load the final model
|
| 137 |
-
model = YOLO('models/yolov8m_stage2_improved_best.pt')
|
| 138 |
-
|
| 139 |
-
# Detect vehicles in image
|
| 140 |
-
results = model('highway_image.jpg')
|
| 141 |
-
|
| 142 |
-
# Process results
|
| 143 |
-
for result in results:
|
| 144 |
-
boxes = result.boxes
|
| 145 |
-
for box in boxes:
|
| 146 |
-
x1, y1, x2, y2 = box.xyxy[0]
|
| 147 |
-
conf = box.conf[0]
|
| 148 |
-
cls = int(box.cls[0])
|
| 149 |
-
class_name = model.names[cls]
|
| 150 |
-
print(f"Detected: {class_name} (confidence: {conf:.2f})")
|
| 151 |
-
```
|
| 152 |
-
|
| 153 |
-
### Video Processing with Counting
|
| 154 |
-
```python
|
| 155 |
-
# Process video with vehicle counting
|
| 156 |
-
results = model('traffic_video.mp4', save=True, save_txt=True)
|
| 157 |
-
|
| 158 |
-
# The main.py script provides advanced counting and tracking features
|
| 159 |
-
```
|
| 160 |
-
|
| 161 |
-
### Using the Complete Application
|
| 162 |
-
```python
|
| 163 |
-
# Run the full application with counting and visualization
|
| 164 |
-
from main import VehicleCounter
|
| 165 |
-
|
| 166 |
-
counter = VehicleCounter()
|
| 167 |
-
counter.process_video('input_video.mp4', 'output_video.mp4')
|
| 168 |
-
```
|
| 169 |
-
|
| 170 |
-
## Applications
|
| 171 |
-
|
| 172 |
-
- Highway traffic monitoring
|
| 173 |
-
- Vehicle counting and classification
|
| 174 |
-
- Traffic flow analysis
|
| 175 |
-
- Automated surveillance systems
|
| 176 |
-
- Road safety monitoring
|
| 177 |
-
- Traffic data collection
|
| 178 |
-
|
| 179 |
-
## Related Repositories
|
| 180 |
-
|
| 181 |
-
- **Full Dataset**: [highway-vehicle-detection-full](https://huggingface.co/datasets/bichuche0705/highway-vehicle-detection-full) - Complete project with datasets and videos
|
| 182 |
-
- **Model Only**: [highway-vehicle-detection](https://huggingface.co/bichuche0705/highway-vehicle-detection) - Just the trained model
|
| 183 |
-
|
| 184 |
-
## License
|
| 185 |
-
|
| 186 |
-
MIT License - Free to use for research and commercial purposes
|
| 187 |
-
|
| 188 |
-
## Contributing
|
| 189 |
-
|
| 190 |
-
This is a research project. For questions or improvements, please contact the author.
|
| 191 |
-
|
| 192 |
-
## Contact
|
| 193 |
-
|
| 194 |
-
**Author**: Nguyen Quoc Viet
|
| 195 |
-
**Repository**: https://huggingface.co/bichuche0705/highway-vehicle-detection-code
|
| 196 |
-
|
| 197 |
-
## Citation
|
| 198 |
-
|
| 199 |
-
If you use this model in your research, please cite:
|
| 200 |
-
|
| 201 |
-
```bibtex
|
| 202 |
-
@misc{highway-vehicle-detection-code,
|
| 203 |
-
title={Highway Vehicle Detection - Code \& Models},
|
| 204 |
-
author={Nguyen Quoc Viet},
|
| 205 |
-
year={
|
| 206 |
-
url={https://huggingface.co/bichuche0705/highway-vehicle-detection-code}
|
| 207 |
-
}
|
| 208 |
-
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- computer-vision
|
| 5 |
+
- object-detection
|
| 6 |
+
- yolov8
|
| 7 |
+
- vehicle-detection
|
| 8 |
+
- traffic-analysis
|
| 9 |
+
- highway-monitoring
|
| 10 |
+
library_name: ultralytics
|
| 11 |
+
pipeline_tag: object-detection
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Highway Vehicle Detection - Code & Models
|
| 15 |
+
|
| 16 |
+
A complete vehicle detection system for highway traffic monitoring. This repository contains the trained models, source code, and documentation - ready to use without requiring dataset downloads.
|
| 17 |
+
|
| 18 |
+
## Quick Start
|
| 19 |
+
|
| 20 |
+
### Installation
|
| 21 |
+
```bash
|
| 22 |
+
pip install ultralytics opencv-python numpy
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
### Basic Usage
|
| 26 |
+
```python
|
| 27 |
+
from ultralytics import YOLO
|
| 28 |
+
|
| 29 |
+
# Load the trained model
|
| 30 |
+
model = YOLO('models/yolov8m_stage2_improved_best.pt')
|
| 31 |
+
|
| 32 |
+
# Run inference on an image
|
| 33 |
+
results = model('path/to/image.jpg')
|
| 34 |
+
results[0].show()
|
| 35 |
+
|
| 36 |
+
# Process video
|
| 37 |
+
results = model('path/to/video.mp4', save=True)
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### Using the Main Application
|
| 41 |
+
```bash
|
| 42 |
+
python main.py
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Repository Contents
|
| 46 |
+
|
| 47 |
+
### Trained Models
|
| 48 |
+
- `models/yolov8m_stage2_improved_best.pt` - **Final model** (recommended)
|
| 49 |
+
- `models/yolov8m_stage1_smart_best.pt` - Stage 1 model (for comparison)
|
| 50 |
+
|
| 51 |
+
### Source Code
|
| 52 |
+
- `main.py` - Complete vehicle detection and counting application
|
| 53 |
+
- `example_usage.py` - Simple usage examples
|
| 54 |
+
- `requirements.txt` - Python dependencies
|
| 55 |
+
- `test_improved_model.bat` - Windows testing script
|
| 56 |
+
|
| 57 |
+
### Fine-tuning Dataset
|
| 58 |
+
- `finetune_dataset/images/` - 92 fine-tuning images
|
| 59 |
+
- `finetune_dataset/labels/` - Corresponding annotation files
|
| 60 |
+
- `finetune_dataset/README.dataset.txt` - Dataset information
|
| 61 |
+
- `finetune_dataset/README.roboflow.txt` - Roboflow export info
|
| 62 |
+
|
| 63 |
+
### Configuration
|
| 64 |
+
- `dataset_configs/main_data.yaml` - Main dataset configuration (8 classes)
|
| 65 |
+
- `dataset_configs/finetune_data.yaml` - Fine-tuning dataset configuration
|
| 66 |
+
|
| 67 |
+
### Training Logs
|
| 68 |
+
- `training_logs/stage2_results.png` - Training results visualization
|
| 69 |
+
- `training_logs/stage2_confusion_matrix.png` - Confusion matrix
|
| 70 |
+
- `training_logs/stage2_results.csv` - Detailed training metrics
|
| 71 |
+
- `training_logs/stage2_val_batch0_pred.jpg` - Sample validation predictions
|
| 72 |
+
|
| 73 |
+
### Training Runs Structure
|
| 74 |
+
- `training_runs/stage1_smart/` - Stage 1 training configuration and weights
|
| 75 |
+
- `args.yaml` - Training arguments
|
| 76 |
+
- `weights/last.pt` - Last epoch weights
|
| 77 |
+
- `training_runs/stage2_improved/` - Stage 2 training configuration and weights
|
| 78 |
+
- `args.yaml` - Training arguments
|
| 79 |
+
- `weights/last.pt` - Last epoch weights
|
| 80 |
+
- `BoxF1_curve.png` - F1 score curve
|
| 81 |
+
- `BoxPR_curve.png` - Precision-Recall curve
|
| 82 |
+
- `labels.jpg` - Label distribution visualization
|
| 83 |
+
|
| 84 |
+
### Documentation
|
| 85 |
+
- `PROJECT_REPORT.md` - Complete project documentation
|
| 86 |
+
- `README.md` - This file
|
| 87 |
+
|
| 88 |
+
## Model Performance
|
| 89 |
+
|
| 90 |
+
### Classes Detected
|
| 91 |
+
1. **auto** - Three-wheelers
|
| 92 |
+
2. **bus** - Public transport vehicles
|
| 93 |
+
3. **car** - Passenger cars
|
| 94 |
+
4. **lcv** - Light Commercial Vehicles
|
| 95 |
+
5. **motorcycle** - Two-wheelers
|
| 96 |
+
6. **multiaxle** - Multi-axle heavy vehicles
|
| 97 |
+
7. **tractor** - Agricultural/construction vehicles
|
| 98 |
+
8. **truck** - Heavy vehicles
|
| 99 |
+
|
| 100 |
+
### Training Stages
|
| 101 |
+
- **Stage 1**: Initial training on 8,219 highway images
|
| 102 |
+
- **Stage 2**: Fine-tuning on 92 additional images for improved truck/bus detection
|
| 103 |
+
|
| 104 |
+
### Fine-tuning Dataset Details
|
| 105 |
+
- **Images**: 92 carefully selected highway images
|
| 106 |
+
- **Focus**: Improved detection of trucks and buses
|
| 107 |
+
- **Classes**: Enhanced examples for problematic vehicle types
|
| 108 |
+
- **Format**: YOLO format with bounding box annotations
|
| 109 |
+
- **Quality**: High-quality images with clear vehicle visibility
|
| 110 |
+
|
| 111 |
+
## External Resources
|
| 112 |
+
|
| 113 |
+
### Test Video
|
| 114 |
+
Watch the model in action on YouTube:
|
| 115 |
+
[Highway Vehicle Detection Demo](https://www.youtube.com/watch?v=wqctLW0Hb_0&list=PLJKyZ_NuOhJQzif2-6-Kq9OiOj_UjJWvi)
|
| 116 |
+
|
| 117 |
+
### Main Dataset
|
| 118 |
+
Download the complete training dataset from Kaggle:
|
| 119 |
+
[Vehicle Detection 8 Classes Dataset](https://www.kaggle.com/datasets/sakshamjn/vehicle-detection-8-classes-object-detection/data)
|
| 120 |
+
|
| 121 |
+
## Technical Details
|
| 122 |
+
|
| 123 |
+
- **Architecture**: YOLOv8m (Medium)
|
| 124 |
+
- **Framework**: Ultralytics YOLO
|
| 125 |
+
- **Input**: Images/Videos
|
| 126 |
+
- **Output**: Bounding boxes with class labels and confidence scores
|
| 127 |
+
- **Hardware**: CPU/GPU compatible
|
| 128 |
+
|
| 129 |
+
## Usage Examples
|
| 130 |
+
|
| 131 |
+
### Vehicle Detection
|
| 132 |
+
```python
|
| 133 |
+
from ultralytics import YOLO
|
| 134 |
+
import cv2
|
| 135 |
+
|
| 136 |
+
# Load the final model
|
| 137 |
+
model = YOLO('models/yolov8m_stage2_improved_best.pt')
|
| 138 |
+
|
| 139 |
+
# Detect vehicles in image
|
| 140 |
+
results = model('highway_image.jpg')
|
| 141 |
+
|
| 142 |
+
# Process results
|
| 143 |
+
for result in results:
|
| 144 |
+
boxes = result.boxes
|
| 145 |
+
for box in boxes:
|
| 146 |
+
x1, y1, x2, y2 = box.xyxy[0]
|
| 147 |
+
conf = box.conf[0]
|
| 148 |
+
cls = int(box.cls[0])
|
| 149 |
+
class_name = model.names[cls]
|
| 150 |
+
print(f"Detected: {class_name} (confidence: {conf:.2f})")
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### Video Processing with Counting
|
| 154 |
+
```python
|
| 155 |
+
# Process video with vehicle counting
|
| 156 |
+
results = model('traffic_video.mp4', save=True, save_txt=True)
|
| 157 |
+
|
| 158 |
+
# The main.py script provides advanced counting and tracking features
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
### Using the Complete Application
|
| 162 |
+
```python
|
| 163 |
+
# Run the full application with counting and visualization
|
| 164 |
+
from main import VehicleCounter
|
| 165 |
+
|
| 166 |
+
counter = VehicleCounter()
|
| 167 |
+
counter.process_video('input_video.mp4', 'output_video.mp4')
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
## Applications
|
| 171 |
+
|
| 172 |
+
- Highway traffic monitoring
|
| 173 |
+
- Vehicle counting and classification
|
| 174 |
+
- Traffic flow analysis
|
| 175 |
+
- Automated surveillance systems
|
| 176 |
+
- Road safety monitoring
|
| 177 |
+
- Traffic data collection
|
| 178 |
+
|
| 179 |
+
## Related Repositories
|
| 180 |
+
|
| 181 |
+
- **Full Dataset**: [highway-vehicle-detection-full](https://huggingface.co/datasets/bichuche0705/highway-vehicle-detection-full) - Complete project with datasets and videos
|
| 182 |
+
- **Model Only**: [highway-vehicle-detection](https://huggingface.co/bichuche0705/highway-vehicle-detection) - Just the trained model
|
| 183 |
+
|
| 184 |
+
## License
|
| 185 |
+
|
| 186 |
+
MIT License - Free to use for research and commercial purposes
|
| 187 |
+
|
| 188 |
+
## Contributing
|
| 189 |
+
|
| 190 |
+
This is a research project. For questions or improvements, please contact the author.
|
| 191 |
+
|
| 192 |
+
## Contact
|
| 193 |
+
|
| 194 |
+
**Author**: Nguyen Quoc Viet
|
| 195 |
+
**Repository**: https://huggingface.co/bichuche0705/highway-vehicle-detection-code
|
| 196 |
+
|
| 197 |
+
## Citation
|
| 198 |
+
|
| 199 |
+
If you use this model in your research, please cite:
|
| 200 |
+
|
| 201 |
+
```bibtex
|
| 202 |
+
@misc{highway-vehicle-detection-code,
|
| 203 |
+
title={Highway Vehicle Detection - Code \& Models},
|
| 204 |
+
author={Nguyen Quoc Viet},
|
| 205 |
+
year={2025},
|
| 206 |
+
url={https://huggingface.co/bichuche0705/highway-vehicle-detection-code}
|
| 207 |
+
}
|
| 208 |
+
```
|