A complete YOLOv8-based object detection system for urban scene analysis. This project provides end-to-end pipelines for data processing, model training, evaluation, and inference with web-based interfaces and REST APIs.
- Object Detection: Detects traffic-related objects (person, car, bus, truck, bicycle, motorcycle) in images and videos
- Multiple Interfaces: Streamlit web app, FastAPI REST endpoints, and CLI tools
- Experiment Tracking: MLflow integration for training and evaluation metrics
- Batch Processing: Concurrent inference for high-throughput processing
- YOLO Format Conversion: Automated COCO to YOLO dataset transformation
project_005/
├── configs/ # YAML configuration files
│ ├── config.yaml # Data processing settings
│ ├── model_params.yaml # Training/evaluation parameters
│ └── pipeline_params.yaml # Inference pipeline settings
├── src/
│ ├── data/ # Data loading, cleaning, feature engineering
│ ├── models/ # Training and evaluation modules
│ ├── pipeline/ # Inference and training orchestration
│ └── utils/ # Logging, exceptions, config parsing
├── scripts/ # Entry points and web interfaces
│ ├── app.py # Streamlit web application
│ ├── single_api.py # FastAPI for single predictions
│ ├── batch_api.py # FastAPI for batch predictions
│ ├── run_infer.py # CLI for batch inference
│ └── index.html # Browser-based frontend
├── notebooks/ # Jupyter notebooks for exploration
├── tests/ # Unit and integration tests
├── docker/ # Docker configuration
├── artifacts/ # Model weights and outputs
└── data/ # Raw and processed datasets
- Python 3.10+
- CUDA (optional, for GPU acceleration)
-
Clone the repository:
git clone <repository-url> cd project_005
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # Linux/Mac # or .\venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Install as editable package (optional):
pip install -e .
Interactive GUI for single and batch detection:
streamlit run scripts/app.pyOpen http://localhost:8501 in your browser.
Single Prediction API (port 8001):
python scripts/single_api.pyBatch Prediction API (port 8000):
python scripts/batch_api.py- Start both API servers (see above)
- Open
scripts/index.htmlin your browser
python scripts/run_infer.py --input-dir path/to/images --output-dir path/to/outputConfiguration files are located in configs/:
| File | Purpose |
|---|---|
config.yaml |
Data paths, download URLs, target classes |
model_params.yaml |
Training epochs, image size, model paths |
pipeline_params.yaml |
Inference settings, confidence thresholds |
The data processing workflow transforms raw COCO-format annotations into YOLO-compatible datasets:
Raw Data → Clean/Filter → YOLO Conversion → Train/Val Split
from src.data.load_data import LoadDataService
from src.data.clean_data import CleanDataService
from src.data.feature_engineering import FeatureEngineering
from pathlib import Path
# Step 1: Download data
LoadDataService(Path("configs/config.yaml")).run()
# Step 2: Filter annotations
CleanDataService(Path("configs/config.yaml")).run()
# Step 3: Convert to YOLO format
FeatureEngineering(Path("configs/config.yaml")).run()Training is configured via configs/model_params.yaml:
python src/models/train_model.pyTraining metrics and artifacts are logged to MLflow. View with:
mlflow uiGenerate evaluation reports from training outputs:
python src/pipeline/evaluate_pipeline.pyThis creates a Markdown report with metrics, confusion matrices, and PR curves.
POST http://localhost:8001/predict
| Parameter | Type | Description |
|---|---|---|
file |
File | Image or video file |
conf_threshold |
float | Confidence threshold (0-1) |
device |
string | cpu or cuda |
POST http://localhost:8000/predict/batch
| Parameter | Type | Description |
|---|---|---|
files |
File[] | Multiple image/video files |
conf_threshold |
float | Confidence threshold (0-1) |
device |
string | cpu or cuda |
Key dependencies include:
ultralytics- YOLOv8 implementationpycocotools- COCO dataset utilitiesmlflow- Experiment trackingstreamlit- Web interfacefastapi/uvicorn- REST API frameworkopencv-python- Image/video processing
See requirements.txt for full list.
Run unit tests with pytest:
pytest tests/This project is licensed under the MIT License.
faker_112