Lucasstranger1 commited on
Commit
ca211ea
·
verified ·
1 Parent(s): 82ef765

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -12,6 +12,7 @@ import streamlit as st # Build the GUI of the application.
12
  from PIL import Image # Handle image operations.
13
  from dotenv import load_dotenv # Load environment variables.
14
  from fer import FER # Import the FER model for facial expression recognition.
 
15
  import openai # OpenAI API for generating text responses.
16
 
17
  #############################################################################################################################
@@ -24,8 +25,11 @@ openai.api_key = os.getenv('OPENAI_API_KEY')
24
  #############################################################################################################################
25
  # Function to query the facial expression recognition model using FER.
26
  def query_emotion(image):
 
 
 
27
  detector = FER()
28
- emotions = detector.detect_emotions(image)
29
 
30
  if emotions:
31
  # Get the emotion with the highest score.
 
12
  from PIL import Image # Handle image operations.
13
  from dotenv import load_dotenv # Load environment variables.
14
  from fer import FER # Import the FER model for facial expression recognition.
15
+ import numpy as np # Import NumPy for array handling
16
  import openai # OpenAI API for generating text responses.
17
 
18
  #############################################################################################################################
 
25
  #############################################################################################################################
26
  # Function to query the facial expression recognition model using FER.
27
  def query_emotion(image):
28
+ # Convert the PIL Image to a NumPy array
29
+ image_np = np.array(image)
30
+
31
  detector = FER()
32
+ emotions = detector.detect_emotions(image_np)
33
 
34
  if emotions:
35
  # Get the emotion with the highest score.