Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
from fer import FER
|
3 |
import cv2
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
@@ -14,7 +14,7 @@ if uploaded_image:
|
|
14 |
# Load the image
|
15 |
image = Image.open(uploaded_image)
|
16 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
17 |
-
|
18 |
# Convert PIL Image to NumPy Array
|
19 |
img_np = np.array(image)
|
20 |
|
@@ -22,7 +22,7 @@ if uploaded_image:
|
|
22 |
img_bgr = cv2.cvtColor(img_np, cv2.COLOR_RGB2BGR)
|
23 |
|
24 |
# Initialize FER detector
|
25 |
-
detector = FER(mtcnn=False)
|
26 |
|
27 |
# Detect emotions
|
28 |
st.write("Analyzing emotions...")
|
@@ -30,7 +30,7 @@ if uploaded_image:
|
|
30 |
|
31 |
if result:
|
32 |
for face in result:
|
33 |
-
emotions = face[
|
34 |
st.write("Detected Emotions:")
|
35 |
st.json(emotions)
|
36 |
else:
|
|
|
1 |
import streamlit as st
|
2 |
+
from fer import FER
|
3 |
import cv2
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
|
|
14 |
# Load the image
|
15 |
image = Image.open(uploaded_image)
|
16 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
17 |
+
|
18 |
# Convert PIL Image to NumPy Array
|
19 |
img_np = np.array(image)
|
20 |
|
|
|
22 |
img_bgr = cv2.cvtColor(img_np, cv2.COLOR_RGB2BGR)
|
23 |
|
24 |
# Initialize FER detector
|
25 |
+
detector = FER(mtcnn=False)
|
26 |
|
27 |
# Detect emotions
|
28 |
st.write("Analyzing emotions...")
|
|
|
30 |
|
31 |
if result:
|
32 |
for face in result:
|
33 |
+
emotions = face["emotions"]
|
34 |
st.write("Detected Emotions:")
|
35 |
st.json(emotions)
|
36 |
else:
|