0% found this document useful (0 votes)
2 views2 pages

Emotion Detection with Anomaly Detection

The document outlines a Python script for anomaly detection in human emotional analysis using a convolutional neural network (CNN). It utilizes OpenCV for face detection and Keras for loading a pre-trained emotion classification model. The script captures video from a webcam, detects faces, and predicts emotions, displaying the results in real-time.

Uploaded by

Shivani Bandi
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)
2 views2 pages

Emotion Detection with Anomaly Detection

The document outlines a Python script for anomaly detection in human emotional analysis using a convolutional neural network (CNN). It utilizes OpenCV for face detection and Keras for loading a pre-trained emotion classification model. The script captures video from a webcam, detects faces, and predicts emotions, displaying the results in real-time.

Uploaded by

Shivani Bandi
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

ANOMALY DETECTION IN HUMAN EMOTIONAL ANALYSIS

EXECUTABLE CODE:
from [Link] import load_model
from time import sleep
from [Link] import img_to_array
from [Link] import image
import cv2
import numpy as np

face_classifier = [Link](r"C:\Users\vanit\Downloads\
Emotion_Detection_CNN-
main\Emotion_Detection_CNN-main\haarcascade_frontalface_default.xml")
classifier = load_model(r"C:\Users\vanit\Downloads\Emotion_Detection_CNN-
main\Emotion_Detection_CNN-main\model.h5")
emotion_labels = ['Angry','Disgust','Fear','Happy','Neutral', 'Sad', 'Surprise']

cap = [Link](0)
while True:
_, frame = [Link]()
labels = []
gray = [Link](frame,cv2.COLOR_BGR2GRAY)
faces = face_classifier.detectMultiScale(gray)

for (x,y,w,h) in faces: [Link](frame,(x,y),


(x+w,y+h),(0,255,255),2) roi_gray =
gray[y:y+h,x:x+w]
roi_gray = [Link](roi_gray,(48,48),interpolation=cv2.INTER_AREA)
if [Link]([roi_gray])!=0:
roi = roi_gray.astype('float')/255.0
roi = img_to_array(roi)
roi = np.expand_dims(roi,axis=0)
prediction = [Link](roi)[0]
label=emotion_labels[[Link]()]
label_position = (x,y)
[Link](frame,label,label_position,cv2.FONT_HERSHEY_SIMPLEX,1,
(0,255,0),2) else:
[Link](frame,'No Faces',(30,80),cv2.FONT_HERSHEY_SIMPLEX,1,(0,255,0),2)
[Link]('Emotion
Detector',frame) if
[Link](1) & 0xFF ==
ord('q'): break

[Link]()
[Link](
)

You might also like