Spaces:
Sleeping
Sleeping
TrinhHuy0911 commited on
Commit ·
dd77e02
1
Parent(s): 099cc48
fix load model
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
| 3 |
from tensorflow.keras.models import load_model
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
-
model = load_model(
|
| 7 |
faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
| 8 |
labels_dict={
|
| 9 |
0:'Angry',
|
|
@@ -17,7 +17,6 @@ labels_dict={
|
|
| 17 |
|
| 18 |
|
| 19 |
def predict_emotion(frame, scaleFactor=1.3, minNeighbors=4,):
|
| 20 |
-
# frame = cv2.imread(r"D:\CODE\PYTHON\Project\Facial_Emotion\Facial Emotion\pic2.jpg")
|
| 21 |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
| 22 |
faces = faceDetect.detectMultiScale(gray, scaleFactor, minNeighbors)
|
| 23 |
for x, y, w, h in faces:
|
|
@@ -42,9 +41,7 @@ with gr.Blocks() as demo:
|
|
| 42 |
<h2 style='text-align: left;'>🤖 Facial Emotion Recognition App</h2>
|
| 43 |
|
| 44 |
**This application detects and classifies **7 human emotions** from facial images using a deep learning model. Simply upload a photo, and the system will analyze facial expressions to predict the most likely emotion.**
|
| 45 |
-
|
| 46 |
**Recognized emotions**: **Angry**, **Disgust**, **Fear**, **Happy**, **Neutral**, **Sad**, **Surprise**.
|
| 47 |
-
|
| 48 |
""")
|
| 49 |
|
| 50 |
with gr.Row():
|
|
@@ -52,7 +49,6 @@ with gr.Blocks() as demo:
|
|
| 52 |
with gr.Column():
|
| 53 |
gr.Markdown("<h3 style='text-align: left;'>📸 Input the picture</h3>")
|
| 54 |
image_input = gr.Image(label="Upload Image", type="numpy", placeholder="Upload an image here",)
|
| 55 |
-
# name_input = gr.Textbox(label="Name", placeholder="Enter your name", info="Your full name")
|
| 56 |
scaleFator_input = gr.Slider(label="ScaleFactor", minimum=1.1, maximum=2, step=0.1, value=1.3, info="scaleFator for face detection")
|
| 57 |
minNeighbors_input = gr.Slider(label="MinNeighbors", minimum=1, maximum=10, step=1, value=4, info="minNeighbors for face detection")
|
| 58 |
Nut1 = gr.Button("Submit", variant="primary")
|
|
|
|
| 3 |
from tensorflow.keras.models import load_model
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
model = load_model('best_model.h5')
|
| 7 |
faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
| 8 |
labels_dict={
|
| 9 |
0:'Angry',
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def predict_emotion(frame, scaleFactor=1.3, minNeighbors=4,):
|
|
|
|
| 20 |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
| 21 |
faces = faceDetect.detectMultiScale(gray, scaleFactor, minNeighbors)
|
| 22 |
for x, y, w, h in faces:
|
|
|
|
| 41 |
<h2 style='text-align: left;'>🤖 Facial Emotion Recognition App</h2>
|
| 42 |
|
| 43 |
**This application detects and classifies **7 human emotions** from facial images using a deep learning model. Simply upload a photo, and the system will analyze facial expressions to predict the most likely emotion.**
|
|
|
|
| 44 |
**Recognized emotions**: **Angry**, **Disgust**, **Fear**, **Happy**, **Neutral**, **Sad**, **Surprise**.
|
|
|
|
| 45 |
""")
|
| 46 |
|
| 47 |
with gr.Row():
|
|
|
|
| 49 |
with gr.Column():
|
| 50 |
gr.Markdown("<h3 style='text-align: left;'>📸 Input the picture</h3>")
|
| 51 |
image_input = gr.Image(label="Upload Image", type="numpy", placeholder="Upload an image here",)
|
|
|
|
| 52 |
scaleFator_input = gr.Slider(label="ScaleFactor", minimum=1.1, maximum=2, step=0.1, value=1.3, info="scaleFator for face detection")
|
| 53 |
minNeighbors_input = gr.Slider(label="MinNeighbors", minimum=1, maximum=10, step=1, value=4, info="minNeighbors for face detection")
|
| 54 |
Nut1 = gr.Button("Submit", variant="primary")
|