Import Packages and Modules

  • OpenCV: OpenCV is a Python open-source package used for computer vision, machine learning, and image processing.
  • Matplotlib: Python’s Matplotlib module is a complete tool for building static, animated, and interactive visualizations.
  • Deepface: A Facebook research team specializing in artificial intelligence developed Deepface. Python provides a framework for analyzing properties and recognizing faces. Keras and TensorFlow both utilize key library elements from Deepface.
  • Requests: Sending HTTP/1.1 requests is incredibly simple with Requests. These days, all you have to do is use the JSON method instead of manually adding query strings to your URLs or form-encoding your PUT and POST data.

Though there are many other ways to recommend music, this implementation is a basic approach. Let’s move forward to the implementation. Install the deepface library in the Python environment.

Python3




!pip install - q deepface


Import the necessary packages.

Python3




import cv2
import requests
import matplotlib.pyplot as plt
from deepface import DeepFace


The path of the image whose expression detection is to be performed should be copied. The image should then be read using the “imread()” method in cv2, the image is stored in the form of an array. Afterward, utilize Matplotlib’s imshow() method to display the image.

Python3




# read the image from location and store
# it in the form of an array
img = cv2.imread("sample.jpg")
# call imshow() using plt object and display the image
plt.imshow(img[:, :, :: -1])
# ensures that the image is displayed
plt.show()


Output:

A Sample image with happy emotion on the face

Emotion Based Music Player – Python Project

In this article, we will be discussing how can we recommend music based on expressions or say dominant expressions on someone’s face. This is a basic project in which we will be using OpenCV, Matplotlib, DeepFace, and Spotify API.

Similar Reads

Import Packages and Modules

OpenCV: OpenCV is a Python open-source package used for computer vision, machine learning, and image processing. Matplotlib: Python’s Matplotlib module is a complete tool for building static, animated, and interactive visualizations. Deepface: A Facebook research team specializing in artificial intelligence developed Deepface. Python provides a framework for analyzing properties and recognizing faces. Keras and TensorFlow both utilize key library elements from Deepface. Requests: Sending HTTP/1.1 requests is incredibly simple with Requests. These days, all you have to do is use the JSON method instead of manually adding query strings to your URLs or form-encoding your PUT and POST data....

Recognizing Emotion using DeepFace

...

Recommending Music using Spotify API

...

Conclusion

...