Giter Site home page Giter Site logo

traffic_flow_management's Introduction

Traffic Flow Management with AI

image

Overview

This repository contains the base code for a Traffic Flow Management system that utilizes artificial intelligence to detect vehicle density, calculate time durations for each lane, and control traffic lights using a microcontroller. The vehicle detection is performed on Google Colab, and the data is then transmitted to the microcontroller through websockets. This project, developed as a part of a school project, incorporates Supervision for vehicle counting in specific zones within each lane. Additionally, the system features a frontend built with Flowbite UI, JQuery, and Socket.io, hosted on localhost:3000. The project serves a Socket.io server on port 3000 for the frontend and a WebSocket server on port 4000 for communication with the microcontroller. The microcontroller uses Mike Causer's TM1637 driver to display relevant information on an LED display.

Features

  • Vehicle Density Detection: The system employs AI-based algorithms to detect and analyze vehicle density in each lane, with vehicle detection performed on Google Colab.

  • Zone-based Vehicle Counting: Supervision is integrated to count the number of vehicles in specific zones within each lane, providing detailed information for traffic analysis.

  • Time Duration Calculation: Based on real-time vehicle density data, the system calculates optimal time durations for traffic lights at each intersection.

  • Microcontroller Integration: The traffic lights are controlled by a microcontroller, which receives the calculated time durations from the AI system through websockets and adjusts the traffic signal accordingly. The microcontroller uses Mike Causer's TM1637 driver to display relevant information on an LED display.

  • Frontend with Flowbite UI: The user interface is built using Flowbite UI, JQuery, and Socket.io, accessible at localhost:3000.

    View preview

    Different Combinations of Light turned on:

  • ๐Ÿ“ก Communications:

    • Webcame < -- > Cloud < -- > Websocket Server
  • Dependencies:

    • Ultralytics: Used for vehicle detection and analysis.
    • Python-SocketIO: Facilitates communication between the AI system, microcontroller, and frontend.
    • Flask: Utilized for serving the frontend and hosting the Socket.io server.
    • Eventlet: Enables WebSocket communication between the AI system and the microcontroller.
    • Supervision: Used for vehicle counting in specific zones.

Prerequisites

  • Python 3.x < 3.12
  • Microcontroller with MicroPython (e.g. Raspberry Pi Pico, Arduino) and Mike Causer's tm1637.py uploaded
  • Google Colab Project (for vehicle detection in the base code)
  • Flowbite UI, JQuery
  • Socket.io

Setup Instructions

  1. Clone the repository (local):

    git clone https://github.com/Nishant1500/Traffic_Flow_Management.git
  2. Upload Notebook file to Google Colab: Upload Enhanced_Traffic_Management.ipynb of /Cloud/ directory.

File: Enhanced_Traffic_Management.ipynb

  1. Install dependencies (local):

    pip install ultralytics python-socketio Flask eventlet

    Install dependencies (cloud): Run the cells and it will install them.

  2. Connect the microcontroller and upload the micropython firmware, and Mike Causer's TM1637 driver > tm1636.py.

  3. Run the main program:

    python index.py
  4. Access the frontend at localhost:3000 to monitor and interact with the traffic flow.

  5. Run the vehicle detection on Google Colab and it pass the detections to the microcontroller through websockets.

License

This project is licensed under the Creative Commons Zero v1.0 Universal License - see the LICENSE file for details.

Acknowledgments

  • Supervision for enhancing vehicle counting accuracy in specific zones.
  • Flowbite UI, JQuery, and Socket.io for the interactive frontend.
  • Mike Causer's TM1637 driver for displaying information on the LED display.
  • Ultralytics, Python-SocketIO, Flask, and Eventlet for efficient communication and web serving.

Feel free to reach out with any questions or feedback. Happy coding!

traffic_flow_management's People

Contributors

nishant1500 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.