GOOGLE AIML INTERNSHIP REPORT

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 36

Summer Industry Internship – II Report

on
Pedestrian Signal Analysis System

During
IV Year I Semester Summer

Submitted to
The Department of Computer Science and Engineering-IOT In
partial fulfillment of the academic requirements of Jawaharlal
Nehru Technological University
For
The award of the degree of
Bachelor of Technology
in
Computer Science and Engineering-IOT By

Yenaganti vignesh
(22315A6902)

Name of Internship Co-ordinator : Mrs. C. Swetha Designation :


Assistant Professor

Sreenidhi Institute of Science and Technology


Yamnampet, Ghatkesar, R.R. District, Hyderabad - 501301
CERTIFICATE

This is to certify that this Summer Industry Internship – II Report on “Artifical Intellience and
Machine”, submitted by yenaganti vignesh (22315A6902) in the year 2024 in partial fulfillment of the
academic requirements of Jawaharlal Nehru Technological University for the award of the degree of
Bachelor of Technology in Computer Science and Engineering-IOT , is a bonafide work in industry
internship that has been carried out during IV B Tech CSE-IOT I Semester Summer, will be
evaluated in IV B Tech CSE-IOT I Semester , under our guidance. This report has not been
submitted to any other institute or university for the award of any degree.

Mrs. C. Swetha Dr. T. Venkat Narayana Rao


Assistant Professor Head of Department CSE-IOT
Department of CSE-IOT
Internship Coordinator

External Examiner

Date:-
DECLARATION

I , YENAGANTI VIGNESH(22315A6902) student of SREENIDHI INSTITUTE OF SCIENCE


AND TECHNOLOGY, YAMNAMPET, GHATKESAR, studying IV year I
semester, CSE-IOT solemnly declare that the Summer Industry Internship-I Report, titled “Artifical
Intellig ence and Machine Learning Internship” is submitted to SREENIDHI INSTITUTE

OF SCIENCE AND TECHNOLOGY for partial fulfillment for the award of degree of
Bachelor of technology in COMPUTER SCIENCE AND ENGINEERING-INTERNET OF
THINGS.

It is declared to the best of our knowledge that the work reported does not form part of any dissertation
submitted to any other University or Institute for award of any degree

YENAGANTI VIGNESH
22315A6902
ACKNOWLEDGEMENT

I would like to express my gratitude to all the people behind the screen who helped me to transform an
idea into a real application.

I would like to thank my Project co-ordinator Mrs. C. Swetha for his technical guidance, constant
encouragement and support in carrying out my project at college.

I profoundly thank Dr. T. Venkat Narayana Rao, Head of the Department of Computer Science &
Engineering –IOT who has been an excellent guide and also a great source of inspiration to my work.
I would like to express my heart-felt gratitude to my parents without whom I would not have been
privileged to achieve and fulfill my dreams. I am grateful to our principal, Dr. T. Ch. Siva Reddy, who
most ably run the institution and has had the major hand in enabling me to do my project.
The satisfaction and euphoria that accompany the successful completion of the task would be great but
incomplete without the mention of the people who made it possible with their constant guidance and
encouragement crowns all the efforts with success. In this context, I would like thank all the other staff
members, both teaching and non-teaching, who have extended their timely help and eased my task.

YENAGANTI VIGNESH

22315A6906
INTERNSHIP CERTIFICATE
INDEX

Page No
1. INTRODUCTION 7-8
1.1 Project Introduction 7
1.2 Scope 7
1.3 Project Overview 8
1.4 Objectives 9
2. SYSTEM ANALYSIS 10
2.1 Performance Requirements 10
2.2 Software Requirements 11-12
2.3 Hardware Requirements 13-16
3. SYSTEM DESIGN 16
3.1 System Architecture 17
4.MODULES 18-19
5. IMPLEMENTATION AND RESULTS 20
5.1 Language / Technology Used 21-22
5.2 Sample Code 23-28
5.3 Results (Accuracy) / Output Screens 29-30
6. TESTING 31
6.1 Types of Testing 32
6.2 Test Cases 32
7. CONCLUSION 33
8. FUTURE SCOPE 34

9. REFERENCES 35
1. INTRODUCTION

1.1 Project Introduction


The Pedestrian Signal Analysis System is an innovative approach toward
improving urban traffic management by introducing a dynamic approach to the
timing of the traffic signals, which will depend on the dynamic real-time analysis
of pedestrian and vehicle volumes. The timings of traditional traffic signals are
fixed for a time period; in fact, wastage occurs in different forms, such as a
longer waiting time for the vehicles and pedestrians, congestion, and increased
potential of accidents. This project will create a system that will fine-tune signal
timings on the go by harnessing the integration of the latest technology in
sensors, cameras, and machine learning algorithms to enhance the flow of traffic
and, at the same time, boost safety for pedestrians and vehicles. The focus is on
important intersections with heavy flows of both pedestrians and vehicles,
creating a more responsive and intelligent traffic management system that could
accommodate the dynamic nature of an urban environment.
In a nutshell, the Pedestrian Signal Analysis System will aspire to bring urban
traffic management closer to an efficient, adaptive, and safe process. This is
believed to make the overall experience relating to urban mobility better by
reducing the waiting times of pedestrians and vehicles, preventing traffic jams,
and reducing accidents. This benefits not only improving the quality of life for
the residents of cities but also attains main goals

1.2 Project Scope

The Pedestrian Signal Analysis System is a mammoth project for research and
development that will focus on designing, developing, implementing, and evaluating
state-of-the-art traffic signal control. The project will kick off by first installing a
network of sensors and cameras at different urban intersections to collect huge data
regarding vehicle and pedestrian movements. These data collection points will
afterwards provide the raw inputs which are necessary in order to develop predictive
models which can be effectively used to forecast both traffic and pedestrian flows.
Other aspects include developing adaptive signal control algorithms capable of
adjusting timings with signals dynamically according to real-time data inputs. This
goes much beyond the mere technical implementation, requiring close cooperation

7
with municipal traffic authorities, city planners, and technology providers aimed at
ensuring the practicality, scalability, and compatibility of the system with existing
infrastructures. The system will be tested for effectiveness over a wide range of urban
locations, embracing geographical and demographic diversity
It will also involve much work on the data analysis and model fine-tuning that
includes real-time monitoring of system performance, data collection pertaining to
both the traffic flow and pedestrian movements, and using this data to fine-tune the
predictive models and adaptive control algorithms. In improving these models, the
project is expected to refine the accuracy and effectiveness of the signal control
system continuously. This is also the loop in which data is collected, analyzed, and the
model updated with the constant changes in urban development and traffic patterns.
Another aspect of the scope of the project involves public engagement and education.
Here, the project sensitizes local communities to the new benefits of the traffic signal
system and solicits responses from road users on what they would like done as the
system is implemented. This feedback will be invaluable in identifying potential
issues and areas for improvement. Public engagement also helps to create project
champions, whereby it ensures
1.3 Project Overview

The Pedestrian Signal Analysis System project is one that seeks to better provisions
for urban traffic management through the implementation of advanced data analytics
and adaptive signal control technologies. The project starts with a comprehensive
requirements analysis and further selection to identify the sites where the first
deployment would take place, bearing in mind the fact that a large number of
pedestrians and vehicles pass through these intersections. Thereafter, a network of
sensors and cameras will be deployed at these junctions to collect real-time data on
traffic volumes and pedestrian movements. This information will be relayed to a
central processing unit, in which information will be processed using machine
learning algorithms to draw predictive models of the intensity of the flow of traffic
and pedestrian activities.
. The project, in essence, aims to show the potentialities and advantages that one can
obtain by integrating real-time data analytics with adaptive signal control in building
an urban traffic management system that is more effective and safe.

8
Project Overview Other than the crucial importance of establishing robust data
infrastructures that allow for real-time collection, the project also includes the
establishment of secure, reliable communication networks that can easily and
efficiently relay data from the point of origin to the central processing unit. This will
also be followed by data storage and management systems that are capable of dealing
with very high volumes of data at any one given time, all done without compromising
on the integrity and security of the data.

1.4 Project Objectives

The Pedestrian Signal Analysis System project ultimately aims at developing and
implementing a dynamic traffic signal control system that properly improves the
efficiency and safety of urban traffic management. It comprises of specific objectives:
reducing pedestrian-vehicle interaction lag time at intersections by dynamic
adjustment of control signal timings based on real-time pedestrian volume
measurements. The overall aim of the project is to make streets safer, enhance overall
road safety, reduce the occurrence of vehicular congestion, and increase traffic flow
with ease without an accident resulting from pedestrians and vehicles at intersections.
The other main focus is to create a solution that is very scalable and can adapt to
different dynamic urban environments with varying traffic situations and
infrastructures.
The project should be expected to encourage and support collaboration and innovation
in urban traffic management from a new outlook. This project brings together experts
in the field from various disciplines in an effort to contribute respective ideas and
approaches that would elleviate the complex challenges in traffic management. By the
same token, the collaborative approach will help create a strong network of
stakeholders able to support the development and implementation of the system.
Besides contributing toward the levels of continuous improvement, the project shall
focus on fostering a level of innovation in culture that would put the system abreast
and at the topmost order of any technological frontier in traffic management.
Lastly, the project furnishes a contribution to larger societal goals pertinent to
sustainability and conservation of the environment. The system helps to cut
emissions, hence contributing to cleaner air, among other advantages, by reducing
congestion and enhancing free traffic mobility. Besides, the system can spearhead
safer interactions
9
2 SYSTEM ANALYSIS

2.1 Performance Requirements

Introduction
The performance requirements of the Pedestrian Signal Analysis System are quite
simple and delineate effectiveness and efficiency for the optimization of traffic flow,
enhance safety, and support urban mobility. The section identifies performance
criteria to be met by the system.

2.1.1 Optimization of Traffic Flow

Other key performance requirements on PSAS relate to the optimization of the traffic flow at
junctions, avoiding congestion, reducing any vehicle's or pedestrian's waiting time in crossing
the road, and generally improving efficiency at intersections. Some performance measures in
optimizing traffic flow include the following:
● The system shall reduce the average wait time of vehicles and pedestrians by some
percentage, say 20%, relative to conventional signal systems.
● Increased capacity of the intersection: It will measure an increased number of vehicles
and pedestrians which can pass an intersection without danger during the peak and
off-peak hours.
● Better Coordination: This would be the degree to which a system coordinates traffic
signals in intersections that provide green waves with reduced stops and delays.

10
2.1.2 Safety and Efficiency of Pedestrian Crossing

Ensure that pedestrian crossing at intersections is safe and efficient, captured


under the following performance requirement:
● Reduced Pedestrian Wait Times: Dynamic signal timings as a result of volume
crossings by pedestrians shall make pedestrians wait at a minimum in a signalized
crosswalk.
● Precise Detection and Recognition: The pedestrian detection shall be automatically
done, then recognize to assure with an exactness degree to very
Scalability: How easily is the system scaled to more intersections or to integrate new sensor
technologies—not at a large lost time in the reconfiguration process ?
● Compatibility: The solution should work with the urban traffic management's existing
infrastructure and the various new and emerging technologies and standards of smart
cities.
● Flexibility: May be defined as flexibility to the system for modifying any parameter,
algorithm or new functionality in respect of any new emerging requirement because
of the traffic management plan and the urban development plan.
2.2 Software Requirements

Introduction
This section will outline the requirements and functionalities for the software
components of the PSAS software requirements, which can only probably allow the
system to collect data on traffic and pedestrians, process it, analyze it, and manage
it. It, therefore, calls for specific software requirements necessary for the execution
of the objectives of the system in this section.
This will involve sensor data collection and processing. On this front, there will be a
requirement for a robust software system that will pick real-time information from
sensors and cameras from intersections, collect it, and process the data. This shall
have the following features:
● Sensor Integration: Software integration with all types of sensors, which can
capture data with respect to vehicle and pedestrian movement .
● Aggregation of multisensor data streams into a common format for analysis
and modeling.

11
Real-Time Processing The software shall provide for real-time processing so that it
can allow the detection of data patterns, computation of traffic flows, and generation
of predictive analytics that support adaptive signal control.

2.2.1 Adaptive Signal Control Algorithms


At the core, however, are the adaptive signal control algorithms capable of changing the
signal timings at runtime due to real-time data inputs. It then boils down into software terms
as follows:
Algorithm Development—Tools and frameworks for developing adaptive signal control
algorithms that merge machine learning and predictive analytics.
Simulation and Testing: Availability of software in which the simulation environments shall
let one test the performance of the algorithms under different traffic scenarios before being
implemented in the field.
● An optimization tool: The signal timings and phases shall get optimized automatically in
accordance with the predictions
that were arrived at by analysis of the traffic flows and historical data.

2.2.2 User Interface and Control


An intuitive user interface is required for PSAS, which shall be used by city planners/traffic
managers to monitor the performance of the system and execute real-time changes.
Following are the software requirements in this regard:
● Dashboards and Visualization: Real-time relevant visualizations of the
traffic flows and signal status and performance metrics dashboards inside the UI.
● Control Mechanisms: Generation and editing of timing signals, pedestrian/vehicle
priority detection, turning off automatic modes in predefined conditions.

2.2.3 Data Storage and Management


Besides that, the PSAS shall store historical data, analyze it, and support long-term planning.
For that, the following shall be required of the software:
● State-of-the-Art Database Integration: It will be able to integrate with state-of-the-art
databases like SQL or NoSQL for huge volumes of sensor data and operation logs.
● Security: Devise safety measures for the protection of sensitive traffic and pedestrian
data from some form of unauthorized access or cyber threat.

12
● Backup and Recovery: Automate mechanisms of backup and recovery procedures to
be adopted in maintaining data integrity and guaranteeing continuity in case of
failures of hardware or disasters.

2.2.4 Integration and Interoperability


The PSAS software shall be designed to allow easy integration into the existing
traffic management systems but probably further integration in the near future into
smart city initiatives. It could, therefore, be necessitated at the software level by:
● Expose API and interface: This would generally imply that internally
developed application program interfaces and interfaces of the system are
kept open to integrate with any third-party applications. This will include
urban mobility, emergency services, and IoT platforms.
● Standards compliance: Industry standards—for instance, ITS standards—so
that deployments work due to interoperability in forthcoming technologies of
smart cities.

● Scalability and Flexibility: The software architecture is targeted to scale for


the introduction of more extensions in the future and adoption of changes in
technology with regards to traffic management.

2.3 Hardware Requirements

Introduction

The PSAS hardware specifications detail the aspects of physical infrastructure that
support software components, data acquisition sensors, and communication
networks with computing resources. This section explains specific hardware

13
requirements imperative to be in place in order to meet the performance and
operational expectations from the system.

2.3.1 Sensor and Camera Systems

The PSAS includes a number of sensors and cameras at any


intersection that collect real-time data related to the flow of traffic
and pedestrian movement. They are as follows:

● Sensors Type: Inductive loops, thermal cameras, artificial


intelligence-enabled cameras, LiDAR sensors, and other
technologies of competencies efficiently detecting and
classifying vehicles and pedestrians.

● Mounting and Installation: Mounting systems to securely


fasten the sensors and cameras; weatherproof enclosures
around them in order to withstand all kinds of outdoor
conditions and continue uninterruptedly at work.

● Power Supplies: Stable sources of power, such as mains


electricity, solar cells, or even a battery backup, shall be
provided to maintain the working continuity of the sensor and
camera systems without any break.

Central Processing Unit

This would mean that some central processing unit would be required to bind
together data collected by the many sensors and cameras, process them, and then
analyze them. Hardware needed in this regard would include the following:
● Servers or Cloud Infrastructure: These give high-performance servers or
cloud-based computing resources for the processing of huge amounts of data
in real-time and running analytics.

14
● Processing Power: The analyzer shall be equipped with a multi-core
processor that will provide appropriate processing power and memory to
execute algorithms in real-time, as well as predictive analytics.
● Storage Capacity: All historization data from PSAS and logs of operation
shall be stored within multi-level storage facilities such as SSD or RAID
arrays.

Communication Network
This dependable communication network contributes a lot in sending data in real-
time from the sensors and cameras into the central processing unit that makes the
system connect. Hardware needed:
● Network Infrastructure: Wired and wireless communication networks shall
be used in its implementation which will help in transferring data like
Ethernet, fibre optic, Wi-Fi, and cellular.
● Bandwidth and Latency: Enough bandwidth should be made available to be
available with very low latency for carrying real-time data from the sensors
to the central processing unit; no delays or line breaks.
● Redundancy and Resilience: Redundant paths of communications and
mechanisms of failover to ensure connectivity and continuity in the transfer
of data in case of network failures.

User Interface and Control Devices

For system performance and analysis of data making live changes, user interface
devices would be required at the respective workstations of the Traffic Managers
who are constantly monitoring and City Planners.
Hardware to be required will be:
● Workstations or Terminals: A desktop computer or a Laptop or some
dedicated terminals with graphical user interface elements which give access
to PSAS dashboards and control panels.
● Touchscreen Display: Touch-enabled display or monitor, to be used for
visualizing real-time traffic and signal status and performance metrics in the
control centers.

15
● Peripheral Devices: Input devices, printers, other peripheral devices for
providing input to PSAS software, generating reports.

Power and Environmental Considerations


The PSAS hardware has to be designed with provisions for environmental
considerations relating to temperature range, humidity, and dust/precipitation to
enable reliable outdoor operations. In this regard, the following hardware would be
needed:
● Environmental Enclosures: Weatherproof enclosures would be necessary to
protect the sensitive electronics and computing equipment deployed at
intersections.
● Temperature Controls: Either the cooling systems or the heat dissipation
mechanisms help maintain the optimum temperature at which servers,
processors, and other hardware components can work.
● Power Backup: UPS or stand-by generators to make good against failures or
fluctuations of power supply.

16
3 SYSTEM DESIGN

3.1 SYSTEM ARCHITECTURE

Fig 3.1 System Architecture

The provided system architecture diagram illustrates the key components and their interactions
within the Pedestrian Signal Analysis System:
● Pedestrian Sensors: These sensors detect pedestrian presence and count, sending data to
the Signal Timing Algorithm through the Communication Network.
● Signal Timing Algorithm: This processing component calculates the optimal signal
timing based on real-time pedestrian data and sends the timing data to the Signal
Controller.
● Signal Controller: This controller changes the pedestrian signal state (e.g., "walk", "don't
walk") based on the timing data received from the Signal Timing Algorithm.
● System Monitor: This component continuously monitors the system's health and reports
statuses to ensure the system operates smoothly.

17
4. MODULES

NUMPY
Numpy is a highly versatile and efficient array-processing library that provides a variety of tools
for working with multidimensional arrays. Its primary use case is in scientific computing with
Python, and it offers a range of essential features thatmake it a fundamental package for data
analysis.
One of Numpy's most significant features is its powerful N-dimensional array manipulation
capabilities. This functionality allows users to easily manipulate and operate on large datasets
with ease, making it an ideal tool for data analysis tasks that involve working with multi-
dimensional arrays.
Numpy also offers sophisticated broadcasting capabilities, which allows for more efficient
computation and manipulation of arrays. Broadcasting is the process of performing operations
on arrays of different shapes and sizes, and Numpy'sbroadcasting capabilities allow users to do
this with ease.
In addition to its array manipulation features, Numpy also provides tools for integrating codes
from different languages like C/C++ and Fortran. This is especially useful for scientific
computing tasks that require the use of external libraries or modules.
Numpy also offers a variety of mathematical functions, including useful linear algebra, Fourier
transform, and random number capabilities. These features make it a highly versatile tool for a
wide range of scientific computing tasks.
Furthermore, it can be used as a highly efficient and flexible container for storing and
manipulating non-specific data. Users can define arbitrary data types using Numpy, allowing for
seamless and rapid integration with a wide variety of databases.
Overall, Numpy is a highly valuable tool for scientific computing and data analysis tasks,
offering a wide range of features and capabilities that enable users to work with large datasets
with ease and efficiency.
OPENCV
OpenCV also called Open Source Computer Vision Library which is a powerful, versatile open
source library primarily focused on real time computer vision and image processing. It is
implemented in C++ but has bindings to many other languages such as Python, Java, and
MATLAB. The numerous functionalities of OpenCV range from image processing, video
capturing to machine learning and deep learning capabilities. In this specific application,

18
OpenCV is used for video capturing, frame reading or preprocessing of images, detection of
objects and visual annotation.
Key Features and Functions in This Application:
Video Capture:
Initialization: cv2.VideoCapture initializes the video capture from either a webcam or a video
file. In this application cap = cv2.VideoCapture(‘videoo.mp4’) will open a video file named
‘videoo.mp4’.
Frame Reading: Processing each frame for object detection involves using cap.read() to read
frames from the video stream within a loop.
Blob Conversion: Transforming units into blobs using cv2.dnn.blobFromImage, since it is
necessary to use frames in the format required for deep learning models. It resizes an image,
normalizes pixel values and reshapes it accordingly with YOLO model input requirements.
Without this step it would not be possible that the model processes the image data accurately.

Time
The time module in Python is an essential library that provides a range of functions for handling
time-related tasks. Though not explicitly used in the provided code, its inclusion can
significantly enhance the functionality and performance of applications, particularly those
dealing with real-time data processing and time-sensitive operations.
It facilitates seamless fusion with popular data science libraries like Pandas and Matplotlib,
streamlining the process of visualizing and sharing insights. Its user-friendly interface enhances
collaboration, allowing teams to iterate rapidly and showcase their work effectively. Streamlit
thus accelerates the development cycle, making data-driven decision-making more accessible
and efficient.
In the context of the traffic monitoring system outlined in the code, the time module can be used
to enhance various aspects of the application. For instance, time-stamping each frame processed
can provide a chronological record of traffic events, helping in post-event analysis and reporting.
Calculating the duration of red light signals dynamically, based on pedestrian and vehicle counts,
can be optimized by accurately measuring processing times. Introducing delays between frame
processing can prevent the system from overloading and ensure smoother operation.

Requests
The Python Requests module significantly simplifies the task of sending HTTP requests and
managing responses smoothly. Its user-friendly interface facilitates seamless interaction with

19
web services, whether retrieving data or submitting forms. Boasting a plethora of features, such
as comprehensive support for diverse HTTP methods and authentication options, Requests
greatly eases the incorporation of web APIs into Python projects. Its popularity derives from its
easy-to-use design and extensive documentation, rendering it a preferred tool among developers
in various sectors. By eliminating intricacies, Requests enables developers to concentrate on
crafting resilient applications, thereby expediting development processes and nurturing
creativity in web-centric endeavors.

Playsound
The playsound module in Python stands out for its simplicity and ease of use, making it an ideal
choice for applications that require basic audio playback capabilities. Unlike more complex
audio libraries, playsound focuses solely on playing sound files, eliminating the need for
intricate setup or extensive code.
The playsound module is a powerful tool for adding audio capabilities to Python applications
with minimal effort. Its simplicity, coupled with its effectiveness in providing auditory feedback,
makes it an excellent choice for alert systems and other use cases where sound playback is
needed. By using playsound, developers can enhance the interactivity and responsiveness of
their applications, ensuring that critical alerts and notifications are delivered effectively to the
users.
5 IMPLEMENTATION

5.1 LANGUAGES USED

● Python:

Python is fairly versatile given its wide libraries, mostly making it a practical choice for
integrating YOLO and for developing the back-end algorithms.
Use: Python will be used to implement the YOLO-based object-detection models, for the
real-time processing of the video, and for its interaction with the rest of the system.

● SQL (Structured Query Language) :

Description: SQL stands for Structured Query Language, designed to manage and query
relational databases—the most demanded process in the storage and retrieval of
structured data.

20
Application: Used to store traffic data, historical records, and performance measures in a
relational database such as PostgreSQL or MySQL.

● HTML/CSS:

Description: For web pages, HTML helps to structure them, and CSS allows information
to be styled giving the presentation and layout.
Application: Design and format interface components, dashboards, and interactive
elements of the web-based system interface.

TECHNOLOGIES AND FRAMEWORKS

1. YOLO (You Only Look Once)

Description: It is an advanced object detection technology that achieves real-time


treatment with the best accuracy in the detection of pedestrians, vehicles, and objects in
general through images and video traffic.
Application of the YOLO model, especially the YOLOv3 and YOLOv4 models, in the
real-time detection of pedestrians and vehicles from cameras mounted at intersections—
making it one of the key data sources for use in the analysis and control of traffic signals.

• Fine-tune the YOLO tool for object detection, model training, and deployment to
optimize the performance of YOLO models.
OpenCV: In this work, implementation tools with libraries for image and video
processing are quite required for preparing input data and post-processing YOLO
approaches to detection.

3. Real-Time Data Processing and Stream Processing:

Apache Kafka and Apache Spark: They allow processing real-time data flows from
cameras located at each intersection, processing input data efficiently, and, in the end,
integrating the results of YOLO detection.
Redis: YOLO detection results are cached in the system, real-time updating of data for
adaptive signal control, and updates on the user interface changes.

4. Cloud Services and Places of Deployment

AWS, Azure, Google Cloud Platform: They avail scalable infrastructure on deployed
YOLO models, handling immense data processing, and backhousing of the backend
services.
Docker, Kubernetes: They avail containerization and orchestration tools, offering
deployment of YOLO and all other system components in scalable and reliable
environments.

21
5. System Integration and Deployment Considerations

Hardware Acceleration: Using GPU hardware acceleration to speed up YOLO inference


for real-time processing and providing high performance to the deployed system. It
should do proper real-time processing for video feeds from the respective intersection
cameras.

Model Optimization: Quantization, pruning, and model compression processes of YOLO


models for the proper optimization that can be deployed into edge or embedded systems
later on.

APIs and Interfaces: The final YOLO detection results are incorporated into the backend
service by using RESTful APIs as an operational technique in order to be maintained in
seamless operation with their respective, adaptive signal control modules, and the data
visualization and management.

6. Benefits of YOLO Integration

Real-Time Object Detection: It should support an accurate and timely detection of


pedestrians and vehicles in video streams for fluid traffic management decisions.

Scalability and Performance: YOLO is efficiency-based and allows the model to be


scaled over several other intersections, encountering different scenarios in traffic and
pedestrian densities.

Improvement in Traffic Safety and Efficiency at Intersections: It would enhance safety at


intersections by enabling detection and priority of pedestrian crossing. For the signal
timings, optimization through real-time traffic information, based on vehicle-
toinfrastructure communication, could be delivered

22
5.2 SAMPLE CODE

detector.py

import cv2
import
numpy as
np import
time
import
requests
from playsound import
playsound import threading

# Constants for time calculation


TIME_PER_PEDESTRIAN = 2
TIME_PER_VEHICLE = 1.5
MIN_RED_TIME = 10
MAX_RED_TIME = 45
ALERT_SOUND = 'audio.mp3'
# URL to Flask app data endpoint
FLASK_DATA_URL = 'http://127.0.0.1:5000/data'

# Load pre-trained models


vehicle_model = cv2.dnn.readNet('./yolov3.weights', './yolov3.cfg')

# Get output layer names


layer_names = vehicle_model.getLayerNames()
output_layers = [layer_names[i - 1] for i in vehicle_model.getUnconnectedOutLayers()]

# Load class names


with
open('coco.names', 'r')
as f:
classes = [line.strip() for line in f.readlines()]

# Initialize video capture (0 for webcam or provide a video file


path) cap = cv2.VideoCapture('videoo.mp4')

def play_alert_sound():
playsound(ALERT_SOUND)

def calculate_red_signal_duration(pedestrian_count, vehicle_count,


base_duration=20, adjustment_pedestrian=0.5, adjustment_vehicle=0.3,
min_duration=5, max_duration=90):
# Calculate adjustments

23
T_P = pedestrian_count * adjustment_pedestrian
T_V = vehicle_count * adjustment_vehicle

# Compute total red signal duration


T_red = base_duration + T_P + T_V

# Ensure duration is within limits


T_red = max(min_duration, min(T_red, max_duration))

return T_red

frame_count = 0

while
cap.isOpened():
ret, frame =
cap.read() if
not ret:
break

frame_count += 1

# Skip frames to reduce


processing load if frame_count
% 5 != 0:
continue

# Prepare the frame for vehicle


detection height, width, channels =
frame.shape
blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), (0, 0, 0), True, crop=False)
vehicle_model.setInput(blob)
detections = vehicle_model.forward(output_layers)

# Initialize counts
pedestrian_count = 0
vehicle_count = 0

# To keep track of already counted pedestrians (centroids)


detected_pedestrians = []

# Lists to hold detection data


for NMS boxes = []
confidences = []
class_ids = []

# Process
detections for

24
detection in
detections:
for obj in
detection:
scores = obj[5:]
class_id =
np.argmax(scores)
confidence = scores[class_id]
if confidence > 0.5:
# Get coordinates for the
bounding box center_x =
int(obj[0] * width) center_y =
int(obj[1] * height) w=
int(obj[2] * width) h =
int(obj[3] * height) x=
int(center_x - w / 2)
y = int(center_y - h / 2)

# Save detection data


boxes.append([x, y, w, h])
confidences.append(float(confidence))
class_ids.append(class_id)

# Apply Non-Maximum Suppression


indices = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)

if len(indices) > 0:
for i in indices.flatten():
box = boxes[i] x,
y, w, h = box
class_id = class_ids[i]
label =
str(classes[class_id])

# Check if the detected object is a


pedestrian if label == 'person':
# Check for double counting
center_x = x + w // 2
center_y = y + h // 2
if not any((abs(center_x - px) < w / 2 and abs(center_y - py) < h / 2) for px, py in
detected_pedestrians):
pedestrian_count += 1
detected_pedestrians.append((center_x, center_y))
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)

# Check if the detected object is a


vehicle elif label in ['car', 'truck',
'bus', 'motorbike']: vehicle_count
+= 1

25
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2)

# Calculate red light duration based on pedestrian and vehicle count


total_red_time = calculate_red_signal_duration(pedestrian_count, vehicle_count)

# Update shared data for Flask app


asynchronously data = {
"pedestrian_count": pedestrian_count,
"vehicle_count": vehicle_count,
"red_light_duration": total_red_time
}
threading.Thread(target=requests.post, args=(FLASK_DATA_URL,), kwargs={'json':
data}).start()

# Display counts and red light time on frame


cv2.putText(frame, f'Pedestrians: {pedestrian_count}', (10, 50),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255,
0, 0), 2)
cv2.putText(frame, f'Vehicles: {vehicle_count}', (10, 100), cv2.FONT_HERSHEY_SIMPLEX, 1,
(0, 255,
0), 2)
cv2.putText(frame, f'Red Light Time: {total_red_time:.1f} sec', (10, 150),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)

# Display red light visual feedback


cv2.circle(frame, (width - 50, 50), 20, (0, 0, 255), -1)

# Play red light alert if the red light duration is above a


threshold if total_red_time > 5: # Adjust the threshold as
needed
threading.Thread(target=play_alert_sound).start()

# Show the frame


cv2.imshow('Frame', frame)
# Check for key press if
cv2.waitKey(1) & 0xFF ==
ord('q'): break

# Release the capture and destroy all windows


cap.release()
cv2.destroyAllWindows()

app.py

26
from flask import Flask, render_template, jsonify,
request import threading

app = Flask(__name__)

# Shared data for pedestrian count, vehicle count, and red light
duration shared_data = { "pedestrian_count": 0,
"vehicle_count": 0,
"red_light_duration": 10
}

@app.route('/') def index():


return
render_template('index.html')

@app.route('/data',
methods=['GET']) def
data(): return
jsonify(shared_data)

@app.route('/increase_duration',
methods=['POST']) def increase_duration():
shared_data["red_light_duration"] +=
10 return jsonify(success=True)

def run_flask():
app.run(debug=True, use_reloader=False)

# Start Flask server in a separate


thread if __name__ ==
"__main__":
threading.Thread(target=run_flask).start()
index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traffic Signal Control</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>Traffic Signal Control</h1>
<p>Pedestrian Count: <span id="pedestrian-count">0</span></p>
<p>Vehicle Count: <span id="vehicle-count">0</span></p>

27
<p>Red Light Duration: <span id="red-light-duration">10</span>
seconds</p> <button id="increase-duration">Increase Duration by
10s</button>

<script>
function updateData() {
$.getJSON('/data', function(data) {
$('#pedestrian-count').text(data.pedestrian_count);
$('#vehicle-count').text(data.vehicle_count);
$('#red-light-duration').text(data.red_light_duration);
});
}

$(document).ready(function() {
updateData();
setInterval(updateData, 1000);

$('#increase-duration').click(function() {
$.post('/increase_duration', function(response) {
if (response.success) {
updateData();
}
});
});
});
</script>
</body>
</html>

PATH SCREENSHOT

28
5.3 RESULTS (ACCURACY) / OUTPUT SCREENS

Fig. 5.3.1 Output screenshot

29
Fig.5.3.2 Output Screenshot 2

30
Fig.5.3.3 Output Screenshot 3

Fig.5.3.4 Output Screenshot 4


6. TESTING

System testing comprises a series of diverse tests aimed at thoroughly exercising the
computerbased system. While each test serves a distinct purpose, all are geared towards
confirming that all system elements have been effectively integrated and are performing their
designated functions. The testing process is conducted to ensure that the product precisely
fulfills its intended purpose. During the testing phase, the following objectives are pursued:
● To affirm the quality of the project.
● To identify and rectify any lingering errors from previous stages.
● To validate the software as a solution to the initial problem.
● To ensure the operational reliability of the system.

Testing Methodologies
There are many different types of testing methods or techniques used as part of the software
testing methodology. Some of the important testing methodologies are:

Unit Testing
Unit testing serves as the foundational stage of testing, typically undertaken by developers
themselves. It involves validating the functionality of individual software components at the
code level to ensure they operate as intended. In environments following test-driven
development practices, developers often create and execute these tests before handing over
the software or feature to the testing team. While unit testing can be performed manually,
automating this process expedites delivery timelines and widens test coverage. Additionally,
automated unit testing facilitates quicker debugging, as detecting and addressing issues early
on reduces the time required compared to identifying them later in the testing cycle. Test Left,
a tool designed to empower advanced testers and developers, supports the shift-left approach
by integrating the fastest test automation tool into any Integrated Development Environment
(IDE).

System Testing
System testing, categorized as a black box testing method, is employed to assess the fully
assembled and integrated system, verifying its compliance with specified requirements. This
testing process entails evaluating the software's functionality from start to finish and is

32
commonly executed by a distinct testing team separate from the development team prior to
product's deployment into production.

User Interface Testing


The evaluation technique of user interface testing pertains to the identification of potential
faults within the graphical user interface (GUI) of a software program orapplication. The
central objective of testing the user interface is to ascertain the software's ease of use,
intuitiveness, and user-friendliness.

6.2 TESTCASES

Test Testcase Category Test Expected Actual (Pass/ Remarks


Scenario ID Data Result Result Fail)

Pedestrian TC001 Functionalit Video Displays PASS Successfully


Should
count y /.mp4 accurate executed
display count
count in
of pedestrians
each frame
Vehicle TC002 Functionalit Video Should Displays PASS Successfully
count y /.mp4 display count accurate executed
of Vehicles count in
each frame
Time for TC003 Functionalit Video Must PASS
Red signal y /.mp4 calculate and Displays the Executed
display signal approximate and
duration red signal displayed as
based on duration expected
counts
Frames TC004 Functionalit Video Should Pedestrians PASS The frames
display y /.mp4 identify and vehicles are
vehicles and displayed
are
pedestrians accurately.
using identified
frames using green

33
7 CONCLUSION

The Pedestrian Signal Analysis System is a project of evolutionary strides toward redefining
city traffic management with state-of-the-art technologies that ensure enhanced pedestrian
safety and improve efficiency in traffic flow. It integrates real-time data acquisition and
stateof-the-art machine learning models for object detection, such as YOLO, with self-tuning
signal control mechanisms that enable dynamic response to the challenges posed by the
modern urban environment.
The PSAS improves intersection safety by detecting pedestrians and vehicles accurately and
adjusts signal timings accordingly. More than that, it is what ensures smooth traffic flow,
reduces congestion, and cuts down delays. What is more, the potential of the system to scale
and be integrated into broader smart city initiatives positions it as the cornerstone for future
urban infrastructure able to evolve with technological advancement and expand to meet
growing cities. Besides robust processing of data and user-friendly interfaces, it is the
performance-driven methodologies that ensure that this PSAS is not just any other
technological solution; rather, it represents a strategic tool for urban planners and traffic
managers all over the world.
The PSAS project concludes with the creation of a vision of innovative mobility in cities
through safety, efficiency, and adaptability, thus giving the pathway to smarter and more
livable cities. It represents a groundbreaking advancement in city traffic management,
leveraging modern technologies to redefine how urban traffic is controlled and optimized.
This project integrates real-time data acquisition with sophisticated machine learning models
for object detection, such as YOLO (You Only Look Once). YOLO's advanced capabilities
enable accurate and rapid identification of pedestrians and vehicles, ensuring that traffic
signals can be dynamically adjusted based on current conditions. The core of the PSAS lies in
its ability to enhance pedestrian safety while simultaneously improving traffic flow. By
accurately detecting pedestrians at intersections, the system adjusts signal timings to ensure
safe crossing opportunities. This dynamic response helps prevent accidents and promotes
safer environments for pedestrians.
Furthermore, by analyzing real-time data, the PSAS can optimize signal timings to smooth
traffic flow, reduce congestion, and minimize delays. This results in a more efficient use of
roadways and a reduction in overall traffic-related issues.

34
8 FUTURE SCOPE

Future Scope of the Pedestrian Signal Analysis System Project:


Having a project based on the effectiveness of the pedestrian signal system, the PSAS project
has a great scope for future developments and extended applications. Currently, the pressure
on developing intelligent traffic management for changing and growing urban environments
is increasing with the fever. A few potential future expansions of this project are considered
below.

1. Integrating Smart City Initiatives into Urban Planning


Description: By doing this, we can easily merge PSAS into other smart city technologies.
Smart IoT devices: Better and more integration of IoT sensors and smart devices into data
collection, enabling richer insights into the real-time flow of traffic along with pedestrian
flow. Advanced environmental sensors, like weather conditions, air quality, and noise level
sensors, further fine-tune tailoring to make much-needed fine adjustments in the strategy to
be adopted for traffic management purposes.
Unified City Platforms: Interconnectedness of other smart city platforms, such as smart street
lighting, waste management, and public safety systems, with each other, would mean that city
planners are empowered with the privilege to make informed decisions because they indeed
correlate toward improving the general urban liveability.

2. Advanced Machine Learning and AI Capabilities


Description: Utilize super-advanced AI and machine learning in a manner that hugely magnifies
predictive and adaptive system capabilities.
Predictive modeling: This involves increasing the sophistication of machine learning models
in order to improve the accuracy of associated traffic flow and pedestrian movement forecasts
through learning from both historical and real-time data on pedestrian or vehicular flow, in
order to predict the increase in time for adjusting signal timings.
Behavioral Analysis : Artificial intelligence can be integrated to explain the behavior of the
pedestrians and drivers more elaborately. For example, it will identify the patterns such as
jaywalking or the pattern of non-compliance with the signals so that proper interventions for
betterment may be designed to integrate with the betterment of traffic conditions.

35
9 REFERENCES

[1] Redmon, J., & Farhadi, A. (2018). YOLOv3: An Incremental Improvement. arXiv preprint
arXiv:1804.02767.

[2] https://arxiv.org/abs/1804.02767

[3] Taylor & Francis Link


Mohan, D., & Tiwari, G. (2020). Road Traffic Injury Prevention Training Manual. World Health
Organization.

[4] https://www.who.int/publications/i/item/road-traffic-injury-prevention-training-manual

[5] [2201.03176] Pedestrian Detection: Domain Generalization, CNNs, Transformers and Beyond
(arxiv.org)

[6] Distributed time-varying formation control with uncertainties based on an event-triggered


mechanism | Science China Information Sciences (springer.com)

[7] Sensors | Free Full-Text | Design and Implementation of a Smart Traffic Signal Control System
for Smart City Applications (mdpi.com)

[8] Sensors | Free Full-Text | Design and Implementation of a Traffic Signal Control System for
City Applications (mdpi.com)

[9] Sensors | Free Full-Text | Integration of IoT-Enabled Technologies and Artificial Intelligence
(AI) for Smart City Scenario: Recent Advancements and Future Trends (mdpi.com)

[10] https://arxiv.org/abs/2111.06740

36

You might also like