How miladnasiri/vlm-based-car-accident-detection-implementation-guide works
This repository implements VLM-based highway accident detection for local video processing and an optional REST API. The main workflow samples video frames, analyzes them with a vision-language model, filters and annotates detections, and writes a JSON report alongside the annotated video. The API accepts uploads, tracks background jobs, and exposes status, downloads, statistics, and GPU information. The map is based on the README and excerpts of the two core files; unsampled implementation details and undocumented connections are omitted.
Main entry points: api-server.py API Endpoints · accident-detection-main.py Video Sampling
Components 16
Video Detection
- CLI Entry
accident-detection-main.py - Video Sampling
accident-detection-main.py - VLM Analysis
accident-detection-main.py - Detection Parsing
accident-detection-main.py - Confidence Filtering
accident-detection-main.py
Detection Results
- Frame Annotation
accident-detection-main.py - Report Generation
accident-detection-main.py - Annotated Video
accident-detection-main.py
REST API
- API Endpoints
api-server.py - Uploaded Videos
api-server.py - Downloads and Stats
api-server.py - GPU Status
api-server.py
Job Operations
- Job Tracking
api-server.py - Background Processing
api-server.py
Other components
- Video Operator
- API Client
Connections 16
- Video Operator → CLI Entry: runs
README.md - CLI Entry → Video Sampling: processes video
accident-detection-main.py - Video Sampling → VLM Analysis: samples frames
README.md - VLM Analysis → Detection Parsing: returns response
accident-detection-main.py - Detection Parsing → Confidence Filtering: produces detections
accident-detection-main.py - Video Sampling → Frame Annotation: annotates frames
accident-detection-main.py - Frame Annotation → Annotated Video: writes frames
accident-detection-main.py - Video Sampling → Report Generation: generates report
accident-detection-main.py - API Client → API Endpoints: submits video
README.md - API Endpoints → Uploaded Videos: saves upload
api-server.py - API Endpoints → Job Tracking: creates job
api-server.py - API Endpoints → Background Processing: schedules task
api-server.py - Background Processing → Video Sampling: processes video
api-server.py - Background Processing → Report Generation: reads report
api-server.py - API Endpoints → Downloads and Stats: serves results
api-server.py - API Endpoints → GPU Status: reports GPU status
api-server.py