44 lines
1.2 KiB
Markdown
44 lines
1.2 KiB
Markdown
# Pothole & Road Sign Detection Backend
|
|
|
|
This project implements a Two-Stage Detection Pipeline using YOLOv8 (for detection & tracking) and CLIP (for zero-shot classification).
|
|
|
|
## Setup
|
|
|
|
1. **Install Dependencies**:
|
|
```bash
|
|
pip install -r backend/requirements.txt
|
|
```
|
|
2. **Training YOLO (Crucial Step)**:
|
|
You MUST train a YOLO model on your custom dataset (Pothole, Manhole, Traffic Signs) for this to work effectively.
|
|
- Prepare your `dataset.yaml`.
|
|
- Run the training script:
|
|
```python
|
|
from backend.models.train_yolo import train_yolo
|
|
train_yolo("path/to/dataset.yaml", epochs=50)
|
|
```
|
|
|
|
- This will generate `best.pt`. Move this file to `backend/models/best.pt`.
|
|
|
|
## Running the API
|
|
|
|
Start the FastAPI server:
|
|
|
|
```bash
|
|
cd backend
|
|
python main.py
|
|
```
|
|
|
|
The server will start at `http://0.0.0.0:8000`.
|
|
|
|
## API Usage
|
|
|
|
**Endpoint**: `POST /detect/video`
|
|
|
|
- **Body**: `multipart/form-data`, key `file` (Video file).
|
|
- **Response**: JSON summary of unique objects detected.
|
|
|
|
## Configuration
|
|
|
|
- Modify `backend/pipelines/video_processor.py` to change the `yolo_model_path` to your trained model path (e.g., `backend/models/best.pt`).
|
|
- You can also adjust the CLA candidate labels in `VideoProcessor.__init__`.
|