|
In this article, we are going to detect the facial expression of an already existing image using OpenCV, Deepface, and matplotlib modules in python. Module Needed
pip install deepface This is the most basic expression detection technique and there are several ways in which we can detect facial expression. Stepwise ImplementationStep 1: Importing the required module. Python3
Step 2: Copy the path of the picture of which expression detection is to be done, read the image using “imread()” method in cv2 providing the path within the bracket. imread() reads the image from the file and stores it in an array. Then use imshow() method of matplotlib. imshow() method converts data into image. Now plot the image using show method in order to ensure that the image has been correctly imported. Python3
Output: Output image Step 3: Create a result variable that will store the result. Use Deepface analyze() method, Deepface analyze() method contains strong facial attribute analysis features such as age, gender, facial expressions. Facial expressions include anger, fear, neutral, sad, disgust, happy, and surprise. Print the result. The result shows the facial expressions percentage of the person. Python3
Output: The result shows that person is 96% happy. Below is the complete implementation: Python3
Output: |
Reffered: https://www.geeksforgeeks.org
Python |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |