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

AI in Data Science Project

The report discusses the implementation of AI for face mask detection, emphasizing its importance during the COVID-19 pandemic for promoting public health and safety. It outlines the objectives, methodology, applications, and impacts of AI in data science, highlighting the benefits of automation and enhanced data analysis. Additionally, it addresses the future scope of AI in data science, including increased automation and improved decision-making.
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)
12 views16 pages

AI in Data Science Project

The report discusses the implementation of AI for face mask detection, emphasizing its importance during the COVID-19 pandemic for promoting public health and safety. It outlines the objectives, methodology, applications, and impacts of AI in data science, highlighting the benefits of automation and enhanced data analysis. Additionally, it addresses the future scope of AI in data science, including increased automation and improved decision-making.
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

REPORT

FOR
AI PROJECT
COURSE CODE: INT404
SECTION: K21ND

PROJECT TITLE: AI in Data Science


Submitted By: Submitted to: Dr. Ahmad Khusro
Name Roll No. Registration Group
No.
Ankit Singh 38 12112817 A
Parihar
Priyanshu 40 12102839 B
Srivastava
Maddukuri Jnana 39 12114318 B
Satya Satwika
TABLE OF CONTENT

1. Introduction
2. Objective
3. Methodology
4. Different Applications of AI in Data Science
5. Impact of AI in Data Science
6. Use Case Diagram
7. Code
8. Results
9. Future Scope
10.Roles and Responsibilities
11.Gantt Chart
12. Conclusion
13. References
INTRODUCTION
Face mask detection using artificial intelligence (AI) is a computer vision technology that uses
machine learning algorithms to automatically detect whether individuals are wearing face masks
or not. With the ongoing COVID-19 pandemic, face masks have become an important measure
to prevent the spread of the virus. AI-based face mask detection systems have been developed to
assist in enforcing mask-wearing policies in public places such as airports, train stations,
shopping malls, and workplaces.
Face mask detection with AI typically involves training a machine learning model using large
datasets of labeled images of people with and without face masks. The model learns to recognize
patterns and features in the images that distinguish between masked and unmasked faces. Once
trained, the model can be deployed in real-time to analyze live video feeds or images from
cameras to identify individuals who are not wearing masks.
The benefits of using AI for face mask detection include increased accuracy, efficiency, and
consistency compared to manual monitoring. AI systems can process large amounts of data
quickly, making them suitable for monitoring crowded spaces in real-time. They can also operate
24/7 without fatigue, making them ideal for continuous surveillance. AI-powered face mask
detection systems can help reinforce mask-wearing policies, promote public health measures,
and contribute to the overall safety and well-being of individuals in public settings.
However, it's important to note that AI-based face mask detection systems are not perfect and
may have limitations. Factors such as lighting conditions, camera angles, mask types, and
occlusions may affect the accuracy of the detection. Ethical considerations, such as privacy
concerns and potential biases, should also be taken into account when implementing AI-based
technologies.
In conclusion, face mask detection with AI is a promising technology that can help in the
enforcement of mask-wearing policies during the COVID-19 pandemic and beyond. It has the
potential to improve public health measures and contribute to a safer environment in public
spaces. However, careful consideration of ethical concerns and limitations of the technology is
necessary for responsible implementation.

Objective:
The main objective of face mask detection with AI is to automatically identify and differentiate
between individuals who are wearing face masks and those who are not, using computer vision
and machine learning techniques. The specific objectives of face mask detection with AI can
include:
1. Enforcing mask-wearing policies: AI-powered face mask detection systems can help
ensure compliance with mask-wearing policies in public places, such as airports, train stations,
shopping malls, and workplaces. By accurately identifying individuals who are not wearing
masks, the system can trigger alerts or notifications to prompt them to wear masks, or to alert
security personnel for further action.
2. Promoting public health measures: Wearing face masks is an important measure to
prevent the spread of infectious diseases, particularly during pandemics like COVID-19. Face
mask detection with AI can help raise awareness and promote the adoption of this public health
measure by providing real-time feedback on mask-wearing compliance in public settings.
3. Enhancing safety and security: AI-based face mask detection systems can contribute to
the safety and security of individuals in public spaces by identifying potential health risks. By
detecting individuals who are not wearing masks, the system can help identify those who may be
violating mask-wearing policies, potentially posing a risk to others in terms of disease
transmission.
4. Improving efficiency and accuracy: Automating face mask detection with AI can
improve the efficiency and accuracy of monitoring compared to manual methods. AI models can
analyze large amounts of data in real-time, operate 24/7 without fatigue, and provide consistent
results, reducing the need for human intervention and potential human errors.
5. Supporting public health campaigns: AI-powered face mask detection systems can be
used as a tool to support public health campaigns aimed at promoting mask-wearing and
preventing the spread of infectious diseases. By providing real-time data on mask-wearing
compliance, these systems can help assess the effectiveness of public health campaigns and
inform decision-making.
Overall, the objective of face mask detection with AI is to leverage advanced technologies to
enhance mask-wearing compliance, promote public health measures, and contribute to the safety
and well-being of individuals in public settings.

Methodology:
1.Importing Libraries: The necessary libraries such as tensorflow.keras, numpy, matplotlib,
and cv2 are imported to build and train the convolutional neural network (CNN) model,
preprocess the images, and perform image-related operations.

2.Mounting Google Drive: The code mounts the Google Drive to access the dataset and save
the trained model.
3.Dataset Preparation: The dataset is prepared by defining the main directory path, train, test,
and validation directory paths, and obtaining the list of file names for mask and non-mask
images.

4.Image Data Generation: ImageDataGenerator from Keras is used to generate augmented


images for training the model. Data augmentation techniques such as rescaling, zooming,
rotation, and horizontal flipping are applied to increase the diversity of the training data and
improve the model's ability to generalize.
5.Model Creation: A sequential CNN model is created using Keras. The model architecture
consists of convolutional layers with activation functions, max pooling layers, dropout layers for
regularization, and dense layers for classification. The model is compiled with the Adam
optimizer, binary cross-entropy loss function, and accuracy as the evaluation metric.
6.Model Training: The model is trained using the prepared training data and validation data.
The number of epochs is set to 10, but it can be adjusted based on the performance of the model.
The training progress is monitored using the validation data to avoid overfitting.
7.Model Evaluation: The trained model is evaluated using the test data to measure its
performance in terms of accuracy and loss.
8.Model Saving: The trained model is saved to the Google Drive for future use.
9.Face Mask Detection: The saved model is loaded, and a video stream from a video file or
webcam is captured. Haar Cascade classifier is used for face detection in the frames of the video
stream. Detected faces are cropped and resized to match the input size of the trained model. The
trained model is then used to predict whether a face has a mask or not. The predicted class label
is displayed on the video stream along with a rectangle around the detected face. The process
continues until the user presses the 'q' key to stop the video stream.
10.Post-processing: The detected faces with predicted class labels are saved as separate images
for further analysis or reporting.

Different application of ai in data science:-

1. Predictive modeling: AI can be used to build predictive models that can analyze data
and make predictions about future outcomes. This can be used in areas such as finance,
healthcare, and marketing.

2. Natural Language Processing (NLP): NLP is a branch of AI that deals with the
interaction between computers and humans using natural language. NLP can be used to
analyze and understand text data, such as social media posts, customer reviews, and chat
logs.

3. Computer Vision: Computer Vision is a branch of AI that deals with the ability of
computers to interpret and analyze visual information from the world around us. This can
be used in areas such as autonomous vehicles, surveillance, and image recognition.

4. Recommender systems: AI can be used to build recommender systems that can analyze
user data and recommend products, services, or content based on their preferences.

5. Fraud detection: AI can be used to detect fraudulent activities in financial transactions,


insurance claims, and other areas.

6. Speech recognition: AI can be used to recognize and transcribe human speech. This can
be used in areas such as customer service, voice assistants, and transcription services.

7. Sentiment analysis: AI can be used to analyze the sentiment of text data, such as social
media posts and customer reviews. This can be used to gauge customer satisfaction,
public opinion, and market trends.

IMPACT OF AI IN DATA SCIENCE:-

Artificial Intelligence (AI) is having a significant impact on data science in several ways. Here
are a few ways in which AI is changing the field of data science:

1.Enhanced Data Analysis: AI technologies such as machine learning, natural language


processing, and deep learning have made it easier to analyze large amounts of data. These
technologies can identify patterns, trends, and insights that humans may miss, helping data
scientists make more informed decisions.

2.Improved Data Quality: AI can help improve the quality of data used in data science. With
the help of AI-powered tools, data scientists can clean, preprocess, and transform data more
efficiently, reducing errors and ensuring that data is accurate, complete, and consistent.

3.Increased Automation: AI is helping automate many data science tasks, such as data
preparation, data analysis, and data visualization. This reduces the time and effort required to
complete these tasks, allowing data scientists to focus on more complex work.

4.Personalization: AI is making it possible to deliver personalized experiences to users based on


their data. For example, AI-powered recommendation systems can provide personalized product
recommendations to customers, based on their purchase history, browsing behavior, and other
data.
5.Real-Time Analytics: With the help of AI-powered technologies, data scientists can perform
real-time analytics, enabling them to respond to changes in data quickly. This is particularly
useful in industries such as finance, healthcare, and e-commerce, where real-time insights can
make a significant difference.

In conclusion, AI is revolutionizing the field of data science by improving data quality,


enhancing data analysis, increasing automation, providing personalized experiences, and
enabling real-time analytics. As AI continues to advance, it is likely that it will play an
increasingly important role in the future of data science.
Use Case Diagram :
CODE:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D , MaxPooling2D,Dropout ,Flatten ,Dense
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import numpy as np
import matplotlib.pyplot as plt
from google.colab import drive
drive.mount('/content/drive')
import os
main_dir = ("/content/drive/My Drive/New Masks Dataset")
train_dir = os.path.join(main_dir,'Train')
test_dir = os.path.join(main_dir,'Test')
valid_dir = os.path.join(main_dir,'Validation')

train_mask_dir = os.path.join(train_dir,'Mask')
train_nomask_dir = os.path.join(train_dir,'Non Mask')
print(train_mask_dir)
train_mask_names =os.listdir(train_mask_dir)
print(train_mask_names[:10])
train_nomask_names =os.listdir(train_nomask_dir)
print(train_nomask_names[:10])
train_datagen =ImageDataGenerator(rescale =1./255,
zoom_range =0.2,
rotation_range= 40,
horizontal_flip= True)

test_datagen =ImageDataGenerator(rescale =1./255)


valid_datagen =ImageDataGenerator(rescale =1./255)

train_generator =train_datagen.flow_from_directory(train_dir,
target_size=(150,150),
batch_size =32,
class_mode ='binary'
)
test_generator=test_datagen.flow_from_directory(test_dir,
target_size=(150,150),
batch_size =32,
class_mode ='binary'
)
valid_generator=valid_datagen.flow_from_directory(valid_dir,
target_size=(150,150),
batch_size =32,
class_mode ='binary'
)

train_generator.class_indices
train_generator.image_shape
model=Sequential()
model.add(Conv2D(32,(3,3),padding ='SAME',activation='relu',input_shape= (150,150,3)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.5))

model.add(Conv2D(64,(3,3),padding ='SAME',activation ='relu'))


model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.5))

model.add(Flatten())

model.add(Dense(256,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1,activation ='sigmoid'))
model.summary()
model.compile(Adam(lr=0.001),loss ='binary_crossentropy',metrics=['accuracy'])
history =model.fit(train_generator,
epochs =10,
validation_data= valid_generator)
test_loss,test_acc =model.evaluate(test_generator)
print('test_acc:{}test loss:{}'.format(test_acc,test_loss))
model.save('/newsaved_model.h5')

import numpy as np
import tensorflow as tf
from google.colab import files
from keras.preprocessing import image

uploaded =files.upload()
#print(uploaded)
for f in uploaded.keys():
img_path ='/content/'+f
img=tf.keras.utils.load_img(img_path,target_size =(150,150))
images =tf.keras.utils.img_to_array(img)
images=np.expand_dims(images,axis =0)
prediction =model.predict(images)
if prediction==0:
print(f,'Mask is present')
else:
print(f,'mask is not present')
import cv2
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import load_img , img_to_array
import numpy as np
from google.colab.patches import cv2_imshow

model = load_model('/content/drive/MyDrive/ai work/input/newsaved_model.h5')

img_width ,img_height =150,150

face_cascade = cv2.CascadeClassifier("/content/drive/MyDrive/ai work/


haarcascade_frontalface_default.xml")

cap =cv2.VideoCapture("/content/drive/MyDrive/ai work/maskvideo.mp4")


cap.open("/content/drive/MyDrive/ai work/maskvideo.mp4")
print(cap.isOpened())
#cap =cv2.VideoCapture('0')
img_count_full =0
font =cv2.FONT_HERSHEY_SIMPLEX
org =(1,1)
class_label =''
fontScale =1
color =(255,0,0)
thickness =2
while True:
img_count_full +=1
response,color_img= cap.read()

if response==False:
break

scale =50
width =int(color_img.shape[1]*scale/100)
height =int(color_img.shape[0]*scale/100)
dim=(width,height)

color_img =cv2.resize(color_img,dim, interpolation =cv2.INTER_AREA)


gray_img =cv2.cvtColor(color_img,cv2.COLOR_BGR2GRAY)
faces=face_cascade.detectMultiScale(gray_img,1.1,6)
img_count =0
for(x,y,w,h) in faces:
org=(x-10,y-10)
img_count+=1
color_face =color_img[y:y+h,x:x+w]
cv2.imwrite('input%d%dface.jpg'%(img_count_full,img_count),color_face)
img=load_img('input%d%dface.jpg'%(img_count_full,img_count),target_size
=(img_width,img_height))
img =img_to_array(img)
img =np.expand_dims(img,axis =0)
prediction =model.predict(img)
if prediction==0:
class_label ="Mask"
color =(0,0,255)
else:
class_label ="No Mask"
color =(0,0,255)
cv2.rectangle(color_img,(x,y),(x+w,y+h),(255,0,0),3)
cv2.putText(color_img,class_label,org,font,fontScale,color,thickness,cv2.LINE_AA)

cv2_imshow(color_img)
if cv2.waitKey(1) & 0xFF==ord('q'):
break

cap.release()
cv2.destroyAllWindows()
RESULT:
FUTURE SCOPE:-
The future scope of AI in data science is vast, as AI is expected to have a significant impact on
the field of data science in the coming years. Here are a few ways in which AI is expected to
shape the future of data science:
1.Increased Automation: AI is expected to automate many of the repetitive and time-
consuming tasks in data science, such as data cleaning, data preprocessing, and model selection.
This will free up data scientists to focus on more complex work, such as model design,
validation, and deployment.
2.Improved Decision-Making: AI is expected to provide data scientists with more accurate and
actionable insights, enabling them to make better-informed decisions. This will be particularly
useful in industries such as healthcare, finance, and marketing, where decisions can have a
significant impact on outcomes.
3.Better Personalization: AI is expected to enable data scientists to deliver more personalized
experiences to users, based on their data. For example, AI-powered recommendation systems can
provide personalized product recommendations to customers, based on their purchase history,
browsing behavior, and other data.
4.Improved Predictive Analytics: AI is expected to improve the accuracy of predictive
analytics by enabling data scientists to identify patterns and trends that are difficult or impossible
to detect using traditional statistical methods. This will be particularly useful in industries such
as manufacturing, logistics, and transportation, where accurate predictions can help optimize
operations and reduce costs.
5.Increased Accessibility: AI is expected to make data science more accessible to a wider range
of people, by automating many of the tasks that require specialized knowledge and expertise.
This will enable more people to use data science tools and techniques to solve real-world
problems.

In conclusion, the future scope of AI in data science is promising, as AI is expected to automate


many tasks, improve decision-making, provide better personalization, improve predictive
analytics, and increase accessibility. As AI continues to evolve, it is likely that it will play an
increasingly important role in the future of data science.
ROLES AND RESPONSIBILITIES:

1. ANKIT SINGH PARIHAR Design & Coding, Use Case Diagram,


Methodology, Future Scope

2. PRIYANSHU SHRIVASTAVA Design & Coding, Objective, Introduction,


Application of AI in Data Science

3.MADDUKURI JNANA SATYA Coding & testing, Conclusion, Impact of


SATWIKA AI in Data Science

GANTT CHART:
CONCLUSION:
In conclusion, AI has become a transformative force in the field of data science, revolutionizing
how data is processed, analyzed, and utilized to derive insights and make informed decisions.
Through the use of advanced machine learning algorithms, deep learning models, and other AI
techniques, data scientists are able to extract valuable knowledge from vast amounts of data,
uncover hidden patterns, and generate predictive models.
AI has been applied across various industries and domains, including healthcare, finance,
marketing, transportation, and many others, to solve complex problems and drive innovation. In
data science, AI has enabled organizations to automate data-driven processes, optimize
operations, and gain a competitive edge by leveraging data as a strategic asset.
Moreover, AI has opened new opportunities in data science, such as natural language processing
(NLP), computer vision, reinforcement learning, and generative models, which have expanded
the scope and capabilities of data science applications. These advancements have led to
breakthroughs in areas such as personalized medicine, fraud detection, recommendation systems,
autonomous vehicles, and virtual assistants, among others.
However, it is important to recognize that ethical considerations, fairness, accountability, and
transparency are crucial in the use of AI in data science. Bias in data, model interpretability,
privacy, and security are challenges that need to be addressed to ensure responsible and ethical
use of AI in data science applications.
In summary, AI has revolutionized the field of data science by enabling organizations to extract
insights and make data-driven decisions that have a significant impact on their operations,
products, and services. The continued advancements in AI and data science will likely unlock
even more possibilities for leveraging data to drive innovation and create value in the future.

REFERENCES:-
1. https://www.kaggle.com/datasets/andrewmvd/face-mask-detection

2. https://pyimagesearch.com/2020/05/04/covid-19-face-mask-detector-with-opencv-keras-
tensorflow-and-deep-learning/

3. https://hevodata.com/learn/artificial-intelligence-in-data-science/

You might also like