SlideShare a Scribd company logo
1 of 29
Internship training report on
Python
SUBMITTED BY
Sahil Verma
II Year
3rd Sem
CS 2nd
4th Oct 2021
At Freecodecamp
1
Facial Emotion
Detection
Introduction to organization
Freecodecamp is India's no.1 internship and training platform with 40000+ free internships
in Engineering, MBA, media, law, arts, and other streams.
They are a technology company on a mission to equip students with relevant skills &
practical exposure through internships and online trainings. Imagine a world full of freedom
and possibilities. A world where you can discover your passion and turn it into your career.
A world where your practical skills matter more than your university degree. A world where
you do not have to wait till 21 to taste your first work experience (and get a rude shock that
it is nothing like you had imagine it to be). A world where you graduate fully assured, fully
confident, and fully prepared to stake claim on your place in the world.
3
Introduction
• The system works on CNN (convolutional neural network) for
extracting the physiological signals and make a prediction. The
results can be drawn out by scanning the person’s image through a
camera and then correlate it with a training dataset to predict
one’s state of emotions.
• DeepFace is the most lightweight face recognition and facial
attribute analysis library for Python.
• OpenCV is a vast library that helps in providing various functions
for image and video operations.
4
Purpose
5
• Recognizing facial expressions would help systems to
detect if people were happy or sad as a human being can.
This will allow software’s and AI systems to provide an even
better experience to humans in various applications.
• Can be used in multiple AI tools to get user feedback.
• It can be used to improve access and security.
Scope
✖ Facial Detection — Ability to detect the location of
face in any input image or frame. The output is the
bounding box coordinates of the detected faces
✖ Emotion Detection — Classifying the emotion on the
face as happy, angry, sad, neutral, surprise, disgust or
fear
6
Project
Let’s Start Exploring it.
7
“Artificial Intelligence is the art of making
computers that behave like the ones in
movies”
--Bill Bulko
8
Software Requirements
Python 3.8.8
Anaconda3
Mamba (RAD)
Jupyter Notebook
Opencv library
Deepface library
VSCode
Requirement specifications
9
Overall Architecture
Receive input frame
from the webcam
10
Identify faces
in the webcam
and prepare
these images
for the deep
learning
models
Send
processe
d faces to
the
models
Render prediction
outcomes with
bounding boxes to
screen
Face Image Recognition
Pre-stored image
11
Capturing Live Video
Opencv
Webcam Output
12
Python provides various libraries for image and video processing.
One of them is OpenCV.
OpenCV is a vast library that helps in providing various functions for
image and video operations. With OpenCV, we can capture a video
from the camera. It lets you create a video capture object which is
helpful to capture videos through webcam and then you may perform
desired operations on that video.
Capturing Live Video
13
We can build very interesting applications using the live video
stream from the webcam. OpenCV provides a video capture
object which handles everything related to opening and
closing of the webcam. All we need to do is create that object
and keep reading frames from it.
The following code will open the webcam, capture the
frames, scale them down by a factor of 2, and then display
them in a window. You can press the Esc key to exit.
Source Code
14
Steps to capture video
15
• Use cv2.VideoCapture() to get a video capture object for the camera.
• Set up an infinite while loop and use the read() method to read the frames using
the above created object.
• Use cv2.imshow() method to show the frames in the video.
• Breaks the loop when the user clicks a specific key.
Facial Detection
16
For face emotion recognition I will not train data sample either rather we
can use a pre-trained Deep Learning library which is deepface. It contains
lot of pre-trained Deep Learning architectures for face emotion recognition.
This library scans the input image and returns the bounding box
coordinates of all detected faces
Input Output
Advantages Of DeepFace
17
You may ask yourself why you should use the deepface library over
alternatives? I think those are the most important reasons why people use
DeepFace to build facial recognition applications:
1. It is lightweight
2. It’s easy to Install
3. Multiple Models and Detectors
4. Open Source Face Recognition
5. Growing deepface Community
6. Language-Independent Package
Integration Of Opencv-python Explained
18
Basically, openCV captures video from your webcam. For every frame, it will
convert it to RGB format. This RGB frame will be sent to detect_face function,
which firstly detects all the faces in the frame using
haar_cascade_frontal_face.xml and for every face, predicts using the 3 trained
models to generate outcomes. These outcomes are returned together with the
face bounding box locations (top, right, bottom, left).
OpenCV then makes use of the bounding box locations to draw rectangle on the
frame and display prediction outcomes in text.
Implementation of the detect_face function can be found in the source code. Note
that since emotion model is trained from grey-scale images, RGB image needs to
be grey-scaled before being predicted by emotion model.
Drawing Rectangle across face
19
Input Output
20
1. Obtain facial bounding box from haar
2. Find the center point of the bounding box
3. Find the maximum between the height and width of the bounding box
4. Draw new bounding box based on the center and maximum side length
5. Resize the cropped face from the new bounding box to the required size
An ideal cropped face photo should have the face located at the center with
no distortion and the required size. If the required size is a square, the
following method does the trick.
Integration Of cv2, deepface, and haarcascade
21
Humans are used to taking in non verbal cues from facial emotions. Now
computers are also getting better to reading emotions. So how do I detect
emotions in an image? I have used an open source data set — Face Emotion
Recognition (FER from DeepFace and built a CNN to detect emotions.
The emotions can be classified into 7 classes — happy, sad, fear, disgust, angry,
neutral and surprise.
Inserting text
Results in live emotion
detection
22
Opencv
(live camera)
Deepface
(face detection)
Working
Total success!
Surprised Cena as Input
23
Detect the face by pre-build
libraries and distinguishing
it with green rectangle
Matched with the library
models for the emotion
detection
DeepFace.verify(img1_path =
"img1.jpg", img2_path =
"img2.jpg")
Source Code
24
25
I was able to open a window and see myself on the screen, however
the moment I tried to change my facial expressions the window
crashed and not responding. I consulted with my colleagues who ran
into similar problems on his MacBook, but not his iMac at home. I
researched the issue online and soon found that many users are
having this issue, and none of the solutions helped. The Stack
Overflow posts by other users here and here describe my exact issue. I
tried numerous solutions but nothing worked to my satisfaction. For
instance, I was able to take only few expressions, but this was
unsuitable for the live demonstration that I am building.
Problem While Execution
26
Conclusion
• Live Emotion Recognition would help systems to detect if people
were happy or sad as a human being can.
• This will also allow software’s and AI systems to provide an even
better experience to humans in various applications.
• Can be used in multiple AI tools to get user feedback.
Reference
• The Opencv for recording live camera is taken from
Geeksforgeeks.org
• Deepface for the face detection is taken from viso.ai
• HaarCascade.xml file for pre-stored expressins models has
been taken from blog masters
haarcascade_frontalface_default.xml file
29
Thanks!

More Related Content

Similar to Python Project.pptx

Discrete Event Simulation, CASE tool built using C#
Discrete Event Simulation, CASE tool built using C#Discrete Event Simulation, CASE tool built using C#
Discrete Event Simulation, CASE tool built using C#Ron Perlmuter
 
Human age and gender Detection
Human age and gender DetectionHuman age and gender Detection
Human age and gender DetectionAbhiAchalla
 
Face recognition application
Face recognition applicationFace recognition application
Face recognition applicationawadhesh kumar
 
IRJET - Emotion Recognising System-Crowd Behavior Analysis
IRJET -  	  Emotion Recognising System-Crowd Behavior AnalysisIRJET -  	  Emotion Recognising System-Crowd Behavior Analysis
IRJET - Emotion Recognising System-Crowd Behavior AnalysisIRJET Journal
 
Color Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible CloakColor Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible CloakAviral Chaurasia
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
Open Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionOpen Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionHemanth Haridas
 
JiyongKim_HHMI report
JiyongKim_HHMI reportJiyongKim_HHMI report
JiyongKim_HHMI reportJiyong Kim
 
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET -  	  Cognitive based Emotion Analysis of a Child Reading a BookIRJET -  	  Cognitive based Emotion Analysis of a Child Reading a Book
IRJET - Cognitive based Emotion Analysis of a Child Reading a BookIRJET Journal
 
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...Amazon Web Services
 
Synopsis of Facial Emotion Recognition to Emoji Conversion
Synopsis of Facial Emotion Recognition to Emoji ConversionSynopsis of Facial Emotion Recognition to Emoji Conversion
Synopsis of Facial Emotion Recognition to Emoji ConversionIRJET Journal
 
Virtual amity | Term Paper | SEM-III
Virtual amity | Term Paper | SEM-IIIVirtual amity | Term Paper | SEM-III
Virtual amity | Term Paper | SEM-IIIVishal Aditya
 
Driver drowsiness monitoring system using visual behaviour and machine learning
Driver drowsiness monitoring system using visual behaviour and machine learningDriver drowsiness monitoring system using visual behaviour and machine learning
Driver drowsiness monitoring system using visual behaviour and machine learningVenkat Projects
 
FACIAL EXPRESSION RECOGNITION 1 2.pptx
FACIAL EXPRESSION RECOGNITION 1 2.pptxFACIAL EXPRESSION RECOGNITION 1 2.pptx
FACIAL EXPRESSION RECOGNITION 1 2.pptxYash670955
 
Cci 2018 creative coding tami belhadj
Cci 2018 creative coding tami belhadjCci 2018 creative coding tami belhadj
Cci 2018 creative coding tami belhadjTami Belhadj
 

Similar to Python Project.pptx (20)

OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
EMOTION DETECTION USING AI
EMOTION DETECTION USING AIEMOTION DETECTION USING AI
EMOTION DETECTION USING AI
 
Discrete Event Simulation, CASE tool built using C#
Discrete Event Simulation, CASE tool built using C#Discrete Event Simulation, CASE tool built using C#
Discrete Event Simulation, CASE tool built using C#
 
Human age and gender Detection
Human age and gender DetectionHuman age and gender Detection
Human age and gender Detection
 
Face recognition application
Face recognition applicationFace recognition application
Face recognition application
 
IRJET - Emotion Recognising System-Crowd Behavior Analysis
IRJET -  	  Emotion Recognising System-Crowd Behavior AnalysisIRJET -  	  Emotion Recognising System-Crowd Behavior Analysis
IRJET - Emotion Recognising System-Crowd Behavior Analysis
 
Color Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible CloakColor Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible Cloak
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
Open Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionOpen Cv – An Introduction To The Vision
Open Cv – An Introduction To The Vision
 
JiyongKim_HHMI report
JiyongKim_HHMI reportJiyongKim_HHMI report
JiyongKim_HHMI report
 
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET -  	  Cognitive based Emotion Analysis of a Child Reading a BookIRJET -  	  Cognitive based Emotion Analysis of a Child Reading a Book
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
 
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
 
Face Scope.pptx
Face Scope.pptxFace Scope.pptx
Face Scope.pptx
 
Synopsis of Facial Emotion Recognition to Emoji Conversion
Synopsis of Facial Emotion Recognition to Emoji ConversionSynopsis of Facial Emotion Recognition to Emoji Conversion
Synopsis of Facial Emotion Recognition to Emoji Conversion
 
Virtual amity | Term Paper | SEM-III
Virtual amity | Term Paper | SEM-IIIVirtual amity | Term Paper | SEM-III
Virtual amity | Term Paper | SEM-III
 
Final year ppt
Final year pptFinal year ppt
Final year ppt
 
Driver drowsiness monitoring system using visual behaviour and machine learning
Driver drowsiness monitoring system using visual behaviour and machine learningDriver drowsiness monitoring system using visual behaviour and machine learning
Driver drowsiness monitoring system using visual behaviour and machine learning
 
FACIAL EXPRESSION RECOGNITION 1 2.pptx
FACIAL EXPRESSION RECOGNITION 1 2.pptxFACIAL EXPRESSION RECOGNITION 1 2.pptx
FACIAL EXPRESSION RECOGNITION 1 2.pptx
 
ComputerVision.pptx
ComputerVision.pptxComputerVision.pptx
ComputerVision.pptx
 
Cci 2018 creative coding tami belhadj
Cci 2018 creative coding tami belhadjCci 2018 creative coding tami belhadj
Cci 2018 creative coding tami belhadj
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Python Project.pptx

  • 1. Internship training report on Python SUBMITTED BY Sahil Verma II Year 3rd Sem CS 2nd 4th Oct 2021 At Freecodecamp 1
  • 3. Introduction to organization Freecodecamp is India's no.1 internship and training platform with 40000+ free internships in Engineering, MBA, media, law, arts, and other streams. They are a technology company on a mission to equip students with relevant skills & practical exposure through internships and online trainings. Imagine a world full of freedom and possibilities. A world where you can discover your passion and turn it into your career. A world where your practical skills matter more than your university degree. A world where you do not have to wait till 21 to taste your first work experience (and get a rude shock that it is nothing like you had imagine it to be). A world where you graduate fully assured, fully confident, and fully prepared to stake claim on your place in the world. 3
  • 4. Introduction • The system works on CNN (convolutional neural network) for extracting the physiological signals and make a prediction. The results can be drawn out by scanning the person’s image through a camera and then correlate it with a training dataset to predict one’s state of emotions. • DeepFace is the most lightweight face recognition and facial attribute analysis library for Python. • OpenCV is a vast library that helps in providing various functions for image and video operations. 4
  • 5. Purpose 5 • Recognizing facial expressions would help systems to detect if people were happy or sad as a human being can. This will allow software’s and AI systems to provide an even better experience to humans in various applications. • Can be used in multiple AI tools to get user feedback. • It can be used to improve access and security.
  • 6. Scope ✖ Facial Detection — Ability to detect the location of face in any input image or frame. The output is the bounding box coordinates of the detected faces ✖ Emotion Detection — Classifying the emotion on the face as happy, angry, sad, neutral, surprise, disgust or fear 6
  • 8. “Artificial Intelligence is the art of making computers that behave like the ones in movies” --Bill Bulko 8
  • 9. Software Requirements Python 3.8.8 Anaconda3 Mamba (RAD) Jupyter Notebook Opencv library Deepface library VSCode Requirement specifications 9
  • 10. Overall Architecture Receive input frame from the webcam 10 Identify faces in the webcam and prepare these images for the deep learning models Send processe d faces to the models Render prediction outcomes with bounding boxes to screen
  • 12. Capturing Live Video Opencv Webcam Output 12 Python provides various libraries for image and video processing. One of them is OpenCV. OpenCV is a vast library that helps in providing various functions for image and video operations. With OpenCV, we can capture a video from the camera. It lets you create a video capture object which is helpful to capture videos through webcam and then you may perform desired operations on that video.
  • 13. Capturing Live Video 13 We can build very interesting applications using the live video stream from the webcam. OpenCV provides a video capture object which handles everything related to opening and closing of the webcam. All we need to do is create that object and keep reading frames from it. The following code will open the webcam, capture the frames, scale them down by a factor of 2, and then display them in a window. You can press the Esc key to exit.
  • 15. Steps to capture video 15 • Use cv2.VideoCapture() to get a video capture object for the camera. • Set up an infinite while loop and use the read() method to read the frames using the above created object. • Use cv2.imshow() method to show the frames in the video. • Breaks the loop when the user clicks a specific key.
  • 16. Facial Detection 16 For face emotion recognition I will not train data sample either rather we can use a pre-trained Deep Learning library which is deepface. It contains lot of pre-trained Deep Learning architectures for face emotion recognition. This library scans the input image and returns the bounding box coordinates of all detected faces Input Output
  • 17. Advantages Of DeepFace 17 You may ask yourself why you should use the deepface library over alternatives? I think those are the most important reasons why people use DeepFace to build facial recognition applications: 1. It is lightweight 2. It’s easy to Install 3. Multiple Models and Detectors 4. Open Source Face Recognition 5. Growing deepface Community 6. Language-Independent Package
  • 18. Integration Of Opencv-python Explained 18 Basically, openCV captures video from your webcam. For every frame, it will convert it to RGB format. This RGB frame will be sent to detect_face function, which firstly detects all the faces in the frame using haar_cascade_frontal_face.xml and for every face, predicts using the 3 trained models to generate outcomes. These outcomes are returned together with the face bounding box locations (top, right, bottom, left). OpenCV then makes use of the bounding box locations to draw rectangle on the frame and display prediction outcomes in text. Implementation of the detect_face function can be found in the source code. Note that since emotion model is trained from grey-scale images, RGB image needs to be grey-scaled before being predicted by emotion model.
  • 19. Drawing Rectangle across face 19 Input Output
  • 20. 20 1. Obtain facial bounding box from haar 2. Find the center point of the bounding box 3. Find the maximum between the height and width of the bounding box 4. Draw new bounding box based on the center and maximum side length 5. Resize the cropped face from the new bounding box to the required size An ideal cropped face photo should have the face located at the center with no distortion and the required size. If the required size is a square, the following method does the trick.
  • 21. Integration Of cv2, deepface, and haarcascade 21 Humans are used to taking in non verbal cues from facial emotions. Now computers are also getting better to reading emotions. So how do I detect emotions in an image? I have used an open source data set — Face Emotion Recognition (FER from DeepFace and built a CNN to detect emotions. The emotions can be classified into 7 classes — happy, sad, fear, disgust, angry, neutral and surprise. Inserting text
  • 22. Results in live emotion detection 22 Opencv (live camera) Deepface (face detection)
  • 23. Working Total success! Surprised Cena as Input 23 Detect the face by pre-build libraries and distinguishing it with green rectangle Matched with the library models for the emotion detection DeepFace.verify(img1_path = "img1.jpg", img2_path = "img2.jpg")
  • 25. 25
  • 26. I was able to open a window and see myself on the screen, however the moment I tried to change my facial expressions the window crashed and not responding. I consulted with my colleagues who ran into similar problems on his MacBook, but not his iMac at home. I researched the issue online and soon found that many users are having this issue, and none of the solutions helped. The Stack Overflow posts by other users here and here describe my exact issue. I tried numerous solutions but nothing worked to my satisfaction. For instance, I was able to take only few expressions, but this was unsuitable for the live demonstration that I am building. Problem While Execution 26
  • 27. Conclusion • Live Emotion Recognition would help systems to detect if people were happy or sad as a human being can. • This will also allow software’s and AI systems to provide an even better experience to humans in various applications. • Can be used in multiple AI tools to get user feedback.
  • 28. Reference • The Opencv for recording live camera is taken from Geeksforgeeks.org • Deepface for the face detection is taken from viso.ai • HaarCascade.xml file for pre-stored expressins models has been taken from blog masters haarcascade_frontalface_default.xml file