Spaces:
Runtime error
Runtime error
paudelanil
commited on
Commit
•
9794e2a
1
Parent(s):
3a85ccb
fix preprocessing
Browse files
app.py
CHANGED
@@ -34,12 +34,18 @@ def detect_face(image):
|
|
34 |
# Function to classify emotion using the loaded model
|
35 |
def classify_emotion(image):
|
36 |
# Preprocess the image
|
|
|
|
|
37 |
image = np.expand_dims(image, axis=0)
|
38 |
-
image = image / 255.0
|
39 |
|
40 |
# Make prediction using the model
|
41 |
predictions = model.predict(image)
|
|
|
|
|
|
|
42 |
emotion_index = np.argmax(predictions)
|
|
|
43 |
emotion_name = emotion_label_dict[emotion_index]
|
44 |
|
45 |
return emotion_name
|
|
|
34 |
# Function to classify emotion using the loaded model
|
35 |
def classify_emotion(image):
|
36 |
# Preprocess the image
|
37 |
+
image = detect_face(image)
|
38 |
+
image = np.array(image)
|
39 |
image = np.expand_dims(image, axis=0)
|
40 |
+
# image = image / 255.0
|
41 |
|
42 |
# Make prediction using the model
|
43 |
predictions = model.predict(image)
|
44 |
+
|
45 |
+
predictions = tf.nn.softmax(predictions)
|
46 |
+
print(predictions)
|
47 |
emotion_index = np.argmax(predictions)
|
48 |
+
|
49 |
emotion_name = emotion_label_dict[emotion_index]
|
50 |
|
51 |
return emotion_name
|