Abhishek Gola
commited on
Commit
·
0fc8804
1
Parent(s):
a58bc70
Added samples
Browse files- .gitattributes +5 -0
- app.py +34 -9
- examples/gray_face.png +3 -0
- examples/lena.jpg +3 -0
.gitattributes
CHANGED
@@ -14,6 +14,11 @@
|
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.webp filter=lfs diff=lfs merge=lfs -te
|
22 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
23 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
24 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -50,15 +50,40 @@ def detect_expression(input_image):
|
|
50 |
output = visualize(image, dets, fer_res)
|
51 |
return cv.cvtColor(output, cv.COLOR_BGR2RGB)
|
52 |
|
53 |
-
# Gradio
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
if __name__ == "__main__":
|
64 |
demo.launch()
|
|
|
50 |
output = visualize(image, dets, fer_res)
|
51 |
return cv.cvtColor(output, cv.COLOR_BGR2RGB)
|
52 |
|
53 |
+
# Gradio Interface
|
54 |
+
with gr.Blocks(css='''.example * {
|
55 |
+
font-style: italic;
|
56 |
+
font-size: 18px !important;
|
57 |
+
color: #0ea5e9 !important;
|
58 |
+
}''') as demo:
|
59 |
+
|
60 |
+
gr.Markdown("### Facial Expression Recognition (FER) with OpenCV DNN")
|
61 |
+
gr.Markdown("Detects faces and recognizes facial expressions using YuNet + MobileFaceNet ONNX models.")
|
62 |
+
|
63 |
+
with gr.Row():
|
64 |
+
input_image = gr.Image(type="numpy", label="Upload Image")
|
65 |
+
output_image = gr.Image(type="numpy", label="Facial Expression Result")
|
66 |
+
|
67 |
+
# Clear output when new image is uploaded
|
68 |
+
input_image.change(fn=lambda: (None), outputs=output_image)
|
69 |
+
|
70 |
+
with gr.Row():
|
71 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
72 |
+
clear_btn = gr.Button("Clear")
|
73 |
+
|
74 |
+
submit_btn.click(fn=detect_expression, inputs=input_image, outputs=output_image)
|
75 |
+
clear_btn.click(fn=lambda:(None, None), outputs=[input_image, output_image])
|
76 |
+
|
77 |
+
gr.Markdown("Click on any example to try it.", elem_classes=["example"])
|
78 |
+
|
79 |
+
gr.Examples(
|
80 |
+
examples=[
|
81 |
+
["examples/lena.jpg"],
|
82 |
+
["examples/gray_face.png"]
|
83 |
+
],
|
84 |
+
inputs=input_image
|
85 |
+
)
|
86 |
+
|
87 |
|
88 |
if __name__ == "__main__":
|
89 |
demo.launch()
|
examples/gray_face.png
ADDED
![]() |
Git LFS Details
|
examples/lena.jpg
ADDED
![]() |
Git LFS Details
|