0% found this document useful (0 votes)
5 views16 pages

ML_LAB_DOC

The document is a project report on a Flight Fare Predictor using Machine Learning, submitted by U. Krishna Koushik for a Bachelor of Technology degree in Computer Science and Engineering (Data Science). It outlines the project's objectives, methodology, and implementation details, including the use of YOLOv3 for monitoring social distancing in public spaces. The report emphasizes the importance of using machine learning to enhance public safety during the COVID-19 pandemic.

Uploaded by

Krishna Koushik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

ML_LAB_DOC

The document is a project report on a Flight Fare Predictor using Machine Learning, submitted by U. Krishna Koushik for a Bachelor of Technology degree in Computer Science and Engineering (Data Science). It outlines the project's objectives, methodology, and implementation details, including the use of YOLOv3 for monitoring social distancing in public spaces. The report emphasizes the importance of using machine learning to enhance public safety during the COVID-19 pandemic.

Uploaded by

Krishna Koushik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

A Project Report for Machine Learning Lab(22DS604PC) On

Flight Fare Predictor Using Machine Learning


Submitted
to
CMR Technical Campus, Hyderabad

In Partial fulfilment for the requirement of the Award of the Degree of

BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE & ENGINEERING(DATA SCIENCE)
by
U.KRISHNA KOUSHIK
(227R1A67J6)
Under the esteemed guidance of
Mr.M.Kishore Kumar
Assistant Professor

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


CMR TECHNICAL CAMPUS
An UGC Autonomous Institute
Accredited by NBA & NAAC with A Grade
(Approved by AICTE, Affiliated to JNTU, Hyderabad)
Kandlakoya (V), Medchal (M), Hyderabad-501 401
CERTIFICATE

This to certify that, the Presentation entitled “Flight Fare Predictor Using
Machine Learning”is submitted by U.KRISHNA KOUSHIK bearing the Roll
Numbers 227R1A67J6 of B.Tech Computer Science and Engineering(Data
Science), In Partial fulfillment for the requirement of the Presentation and for
the award of the Degree of Bachelor of Technology during the academic year
2024-25.

Subject Faculty
Mr.M.Kishore Kumar
9. ESTD: 2009

CMR TECHNICAL CAMPUS


UGC AUTONOMOUS
Accredited by NBA & NAAC with ‘A’ Grade Approved by AICTE, New Delhi
and JNTU Hyderabad

Academic Year : 2024-2025


Name of the Student : U.KRISHNA KOUSHIK
Roll No : 227R1A67J6
Year : III
Semester : VI
Section :C
Branch : CSD
Name of the Laboratory
: MACHINE LEARNING LAB

Batch no : 23

Name of the Topic : Flight Fare Predictor Using Machine


Learning
Date
:
Signature of the :
Student

Subject Viva - Voce/ PPT/Poster Presentation(PP)/Case Study(CS)


Problem statement & Design & Implementation Total Final
Objectives Methodology & result Marks Marks

15 15 10 40 10

Remarks/Comments by Faculty:

Name of the Faculty: Mr.M.Kishore Kumar

Signature of the Faculty:


TABLE OF CONTENTS

ABSTRACT

INTRODUCTION

SOFTWARE REQUIRED

LITERATURE REVIEW

IMPLEMENTATION

RESULTS

CONCLUSION
ABSTRACT

Social distance monitoring using machine learning is an approach which


uses OpenCV and YOLOv3 algorithm to automating the monitoring of social
distance in public spaces. It uses a pre-trained deep learning model called
YOLOV3 to detect people in a video stream captured by a camera. The program
then calculates the distances between all pairs of detected people and marks the
ones who are within a specified distance threshold as a potential violation of
social distancing rules. The program displays the output video stream in real-
time, with bounding boxes drawn around the detected people and a label
indicating whether they are in violation of social distancing rules or not. The
system continuously monitors the video stream, detects social distancing
violations, and provides visual feedback in real-time. The output can be used to
enforce social distancing in crowded public places to prevent the spread of
infectious diseases and can have further applications like identifying areas to
prioritize disinfecting and cleaning. In response to the COVID-19 pandemic,
maintaining social distance has been a crucial measure to prevent virus
transmission. This project presents a Social Distance Analyzer that utilizes
Machine Learning techniques to monitor and analyze the distance between
individuals in public spaces. This technology can be integrated into surveillance
systems to enhance public safety and ensure compliance with social distancing
guidelines.
INTRODUCTION

The COVID-19[1] pandemic has drastically changed the way we live our lives,
with one of the major changes being the need to maintain social distance to prevent
the spread of the virus. With the increase in population density in urban areas and the
constant movement of people, it has become difficult to ensure that individuals
maintain a safe distance from each other. To address this issue, various technologies
are being developed to monitor social distancing in public places. One such
technology is the use of computer vision algorithms and object detection techniques to
monitor social distancing in real-time. In this approach, cameras are installed in public
places to capture live video feeds, which are then analysed using computer vision
algorithms to detect and track individuals in the scene. Object detection techniques are
then used to identify individuals who are not maintaining a safe distance from others.
In this paper, we present a social distancing monitoring system based on the
YOLOv3(You Only Look Once version 3) object detection algorithm. We
demonstrate the effectiveness of our system in detecting individuals and measuring
the distance between them in real-time[2]. This system can be used to monitor social
distancing in public places such as airports, train stations, supermarkets, and parks to
ensure the safety of individuals and prevent the spread of dangerous viruses.

The need for effective monitoring of social distancing has led to the adoption of
computer vision and deep learning algorithms in public safety applications. By
leveraging advanced object detection models like YOLOv3, the system can efficiently
identify individuals, measure their distances, and detect violations in real-time. This
approach enhances automated surveillance, reducing human intervention while
ensuring compliance with safety guidelines. The integration of OpenCV and machine
learning allows for scalable and adaptable monitoring, making it suitable for crowded
areas such as airports, train stations, and shopping centers. Additionally, the use of
bounding boxes and centroid-based calculations improves accuracy in detecting
proximity.
LITERATURE

The use of computer vision technology in monitoring social distancing has


become increasingly popular due to the COVID-19 pandemic. Various studies have
explored the use of object detection algorithms, such as Social Distancing Monitoring
System based on Machine Learning by Lee et al. (2021): The authors proposed a
social distancing monitoring system using machine learning that can installed in
public places to detect and track the social distancing of people. The proposed system
used a convolutional neural network (CNN)[3] model for object detection and
tracking. Social Distance Detection System using Machine Learning and Thermal
Imaging by Mandal et al. (2021): The authors proposed a social distance detection
system using machine learning and thermal imaging[4]. The system uses a YOLOV3
object detection model to detect the people in the thermal imaging and calculate their
distance based on the pixel ratio. Social Distancing Detection in Public Spaces using
Deep Learning by Agarwal et al. (2021): The authors proposed a social distancing
detection system based on deep learning, which uses a YOLOV3 object detection
model to detect the people and calculate their distance. The proposed system is
evaluated on a public dataset and achieves an accuracy of 94%. Social Distancing
Monitoring Using Deep Learning for COVID-19 by Gupta et al. (2020): The authors
proposed a social distancing monitoring system using deep learning, which uses a
Faster R-CNN (Region-based Convolutional Neural Networks) object detection model
to detect and track people in the video footage. The proposed system is evaluated on a
real-world dataset and achieves an accuracy of 90%.

Public Social Distance Monitoring System Using Object Detection

A study published in SN Computer Science (2023) discusses the


implementation of YOLOv3 for social distancing detection. The model calculates
Euclidean distances between individuals and triggers alerts when violations occur.
The research emphasizes the computational efficiency of Tiny-YOLOv3 compared to
other versions.
SOFTWARE REQUIRED

1.Frontend Technologies
 React.js
Purpose: Building an interactive user interface for real-time monitoring of social
distancing violations.
 HTML5, CSS3, JavaScript
Purpose: Structuring and styling web pages for a seamless user experience.

2. Backend Technologies
 Python (Flask/Django)
Purpose: Server-side scripting and handling backend logic for processing video
feeds.
 OpenCV
Purpose: Image processing and real-time object detection.
 YOLOv3/YOLOv5
Purpose: Deep learning-based object detection for identifying individuals in video
streams.

3. Database Management System


 MySQL / PostgreSQL / MongoDB
Purpose: Storing detected violations, timestamps, and user data for analysis.

4. Authentication and Security


 JWT (JSON Web Tokens)
Purpose: Secure user authentication for system access.
 bcrypt.js
Purpose: Encrypting passwords to ensure data privacy.

5. Development Tools
 Jupyter Notebook / PyCharm
Purpose: Code editor for developing and testing machine learning models.
 Postman
Purpose: Testing API endpoints for data retrieval and processing.

6. Version Control
 Git & GitHub
Purpose: Source code management and collaboration among developers.
IMPLEMENTAION
Source Code:
import cv2
import streamlit as st
import json
import requests
import matplotlib.pyplot as plt
import numpy as np
import imutils
from scipy.spatial import distance as dist
def main():
st.title("Social Distancing Anlyzer Web App")
st.sidebar.title("Social Distancing Anlyzer Web App")
st.markdown("Find total numberr of peoples who are following social-distancing ")
st.sidebar.markdown("Find total numberr of peoples who are following social-distancing ")
filename = open('pedestrians.mp4','rb')
video_bites = filename.read()
st.sidebar.text("Input Video:")
st.sidebar.video(video_bites)
app_mode = st.sidebar.selectbox("Choose the app mode",
["About the App", "Run the app", "Show the source code"])
if app_mode == "About the App":
st.text('This is an app which detects whether the person is following social-distancing or not ')
st.text('over an area with the help of CCTV footage or any video source and plots the data of
same ')
elif app_mode == "Show the source code":
with st.echo():
Link = "https://github.com/shreyanshsatvik/covid_tracer"
elif app_mode == "Run the app":
model = "yolo-coco/yolov3.weights"
cfg = "yolo-coco/yolov3.cfg"
label_path= "yolo-coco/coco.names"
input_location = "pedestrians.mp4"
net = cv2.dnn.readNetFromDarknet(cfg,model)
labels= open(label_path).read().strip().split("\n")
ln= net.getLayerNames()
ln = ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
minimum_threshold=0.3
minimum_probability =0.3
minimum_distance = 50
display = 1
output=""
total_person=[]
number_of_people_violationg_socialdistancing=[]

def detect_people(frame, net, ln, personIdx=0):


(H, W) = frame.shape[:2]
results = []
blob = cv2.dnn.blobFromImage(frame, 1 / 255.0, (416, 416),
swapRB=True, crop=False)
net.setInput(blob)
layerOutputs = net.forward(ln)
boxes = []
centroids = []
confidences = []
# loop over each of the layer outputs
for output in layerOutputs:
# loop over each of the detections
for detection in output:
# extract the class ID and confidence (i.e., probability)
# of the current object detection
scores = detection[5:]
classID = np.argmax(scores)
confidence = scores[classID]
if classID == personIdx and confidence > 0.3:
box = detection[0:4] * np.array([W, H, W, H])
(centerX, centerY, width, height) = box.astype("int")
x = int(centerX - (width / 2))
y = int(centerY - (height / 2))
boxes.append([x, y, int(width), int(height)])
centroids.append((centerX, centerY))
confidences.append(float(confidence))
idxs = cv2.dnn.NMSBoxes(boxes, confidences, 0.3, 0.3)
if len(idxs) > 0:
# loop over the indexes we are keeping
for i in idxs.flatten():
# extract the bounding box coordinates
(x, y) = (boxes[i][0], boxes[i][1])
(w, h) = (boxes[i][2], boxes[i][3])
r = (confidences[i], (x, y, x + w, y + h), centroids[i])
results.append(r)
return results
if st.button('Show Results in the video'):

vs=cv2.VideoCapture(input_location if input_location else 0)


writer =None
while True:
(grabbed, frame) = vs.read()
if not grabbed:
break
frame = imutils.resize(frame, width=700)
results= detect_people(frame, net, ln,
personIdx=labels.index("person"))
violate = set()
if len(results) >= 2:
centroids = np.array([r[2] for r in results])
D = dist.cdist(centroids, centroids, metric="euclidean")
for i in range(0, D.shape[0]):
for j in range(i + 1, D.shape[1]):
if D[i, j] < minimum_distance :
violate.add(i)
violate.add(j)
for (i, (prob, bbox, centroid)) in enumerate(results):
(startX, startY, endX, endY) = bbox
(cX, cY) = centroid
color = (0, 255, 0)
if i in violate:
color = (0, 0, 255)
number_of_people_violationg_socialdistancing.append(len(violate))
total_person.append(len(results))
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.circle(frame, (cX, cY), 5, color, 1)
text = "Social Distancing Violations: {}".format(len(violate))
cv2.putText(frame, text, (10, frame.shape[0] - 25),
cv2.FONT_HERSHEY_SIMPLEX, 0.85, (0, 0, 255), 3)
if display> 0:
cv2.imshow("Frame",frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
filename1 = open('output.mp4','rb')
video_bites1 = filename1.read()
st.text("Output Video:")
st.video(video_bites1)
break
if output != "" and writer is None:
fourcc = cv2.VideoWriter_fourcc(*"MJPG")
writer = cv2.VideoWriter(args["output"], fourcc, 25000000,
(frame.shape[1], frame.shape[0]), True)
if writer is not None:
writer.write(frame)
plt.plot(total_person)
plt.plot(number_of_people_violationg_socialdistancing)
plt.xlabel('Number of Frames')
plt.ylabel('Number of People')
st.pyplot()

if __name__ == "__main__":
main()
RESULTS

The below figure shows video input

The code reads video input from a camera, performs object detection on each frame,
and calculates the distance between detected people. If the distance between two
people is less than a predefined threshold value, they are considered in violation of
social distancing, and their bounding boxes are highlighted in red. The number of
violations is also displayed on the video. The video frames are continuously processed
to detect people and analyze their distances. If the distance between two centroids is
less than the configured minimum distance, it is considered a serious violation. If the
distance is below the maximum distance but above the minimum distance, it is
considered as abnormal violation. The code visualizes the violations on the video
frames. Bounding boxes around the detected people are color-coded based on the
severity of the violation. Serious violations are marked with red boxes, and abnormal
violations are marked with orange boxes. The total number of serious violations and
abnormal violations are displayed on the video frame. The counts are updated in real-
time as the video progresses.
CONCLUSION

In conclusion, social distance detection using YOLOv3 is an effective


method to help ensure compliance with social distancing guidelines during
the ongoing COVID-19 pandemic. The YOLOv3 based social distance
detection code can effectively detect and track persons in real-time video
streams and calculate the distance between them. It can successfully identify
violations of social distancing rules and highlight the violators with a red
rectangle around them. The output video can be saved to a file for further
analysis. By using computer vision and deep learning techniques, YOLOv3
can detect people in real-time video feeds and calculate the distance between
them. This technology has the potential to reduce the spread the spread of
COVID-19 and other infectious diseases by alerting individuals or
authorities when social distancing guidelines are not being followed.
However, it is important to note that social distance detection using YOLOv3
is just one tool in a larger toolbox of measures that can be taken to combat
the pandemic. It is not a substitute for other interventions, such as wearing
masks, washing hands frequently, and getting vaccinated. Furthermore, there
are also some limitations to the accuracy of YOLOv3, particularly when it
comes to crowded areas or when people are partially occluded. Overall,
social distance detection using YOLOv3 has the potential to be a valuable
tool in the fight against COVID-19, but it should be used in conjunction with
other measures and with an understanding of its limitations.
The output video file can be used to monitor compliance with social
distancing norms in public places. The number of violations is displayed in
real-time, and any detected violations can be flagged for further action. The
code can be extended to include additional features such as facial recognition
and temperature detection for enhanced safety measures.
REFERENCES

[1] An article on web Reference of COVID-19

https://www.tandfonline.com/doi/abs/10.1080/10494

820.2020.1813180abstract

[2] An article on Reference of real-time

https://www.sciencedirect.com/science/article/pii/S1

672022923000013

[3] An article on Web Reference of Convolutional

neural networks

https://www.tandfonline.com/doi/abs/10.1080/00207

454.2021.1883602

[4] An article on Web Reference of thermal imaging

https://ieeexplore.ieee.org/abstract/document/10014

654

You might also like