Spaces:
Sleeping
Sleeping
Commit
·
9b07b0d
1
Parent(s):
08f3187
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from PIL import Image
|
|
3 |
import numpy as np
|
4 |
import cv2
|
5 |
import requests
|
6 |
-
|
7 |
import face_recognition
|
8 |
import os
|
9 |
from datetime import datetime
|
@@ -62,17 +62,24 @@ if img_file_buffer is not None:
|
|
62 |
matchIndex = np.argmin(faceDis)
|
63 |
|
64 |
if matches[matchIndex]:
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import numpy as np
|
4 |
import cv2
|
5 |
import requests
|
6 |
+
from gradio_client import Client
|
7 |
import face_recognition
|
8 |
import os
|
9 |
from datetime import datetime
|
|
|
62 |
matchIndex = np.argmin(faceDis)
|
63 |
|
64 |
if matches[matchIndex]:
|
65 |
+
name = classnames[matchIndex]
|
66 |
+
st.write(name)
|
67 |
+
y1, x2, y2, x1 = faceLoc
|
68 |
+
y1, x2, y2, x1 = y1*4,x2*4,y2*4,x1*4
|
69 |
+
cv2.rectangle(image,(x1,y1),(x2,y2),(0,255,0),2)
|
70 |
+
cv2.rectangle(image,(x1,y2-35),(x2,y2),(0,255,0),cv2.FILLED)
|
71 |
+
cv2.putText(image,name,(x1+6,y2-6),cv2.FONT_HERSHEY_COMPLEX,1,(255, 255, 255),2)
|
72 |
+
client = Client("https://rahulsinghpundir-facial-expression.hf.space/")
|
73 |
+
result = client.predict(
|
74 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'img' Image component
|
75 |
+
api_name="/predict"
|
76 |
+
)
|
77 |
+
if result == "happy":
|
78 |
+
##############
|
79 |
+
url = "https://kiwi-whispering-plier.glitch.me/update"
|
80 |
+
|
81 |
+
data = {
|
82 |
+
'name': name,
|
83 |
+
}
|
84 |
+
else:
|
85 |
+
st.write("Please smile")
|