CoolFace
Apppublic

iju123/AL_Assisted_Traffic_light_Control_system

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿšฆ AI-Assisted Traffic Light Control System

This is a real-time AI traffic light controller built with YOLOv8 + PyTorch + Gradio. It detects cars, trucks, and ambulances from camera feeds and gives priority to ambulances in traffic.


โœจ Features

  • โ€”Detects cars, trucks, ambulances from live video/images
  • โ€”If an ambulance is detected โ†’ traffic light turns GREEN โœ…
  • โ€”Trucks can be double-checked with an optional ambulance classifier
  • โ€”Built with Gradio for easy deployment and usage
  • โ€”Runs on Hugging Face Spaces (no setup needed)

๐Ÿ› ๏ธ How It Works

  1. 1.YOLOv8 model detects vehicles in the frame.
  2. 2.If YOLO labels a vehicle as a truck, we optionally pass it to a small CNN classifier:
  3. 3.ambulance_classifier.pth โ†’ determines if it's an ambulance.
  4. 4.If missing โ†’ fallback to YOLO only.
  5. 5.Traffic rules (`traffic_logic.py`):
  6. 6.Ambulance โ†’ ๐Ÿšฆ GREEN LIGHT (priority passage)
  7. 7.Otherwise โ†’ ๐Ÿšฆ Normal rules for cars & trucks.

๐Ÿš€ Run Locally

Clone the repo and install dependencies:

bash
git clone https://huggingface.co/spaces/your-username/traffic-light-ai
cd traffic-light-ai
pip install -r requirements.txt