Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
# from transformers import pipeline
|
3 |
from PIL import Image
|
4 |
import face_recognition
|
5 |
import cv2
|
@@ -59,13 +59,17 @@ if file_name is not None:
|
|
59 |
|
60 |
y1, x2, y2, x1 = faceLoc
|
61 |
y1, x2, y2, x1 = (y1 * 4), (x2 * 4), (y2 * 4) ,(x1 * 4)
|
62 |
-
cv2.rectangle(test_image , (x1, y1), (x2, y2), (0, 255, 0), 2)
|
63 |
-
cv2.rectangle(test_image , (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
|
64 |
-
cv2.putText(test_image , name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
|
65 |
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
else:
|
68 |
-
|
69 |
|
70 |
# image = Image.open(file_name)
|
71 |
# col1.image(image, use_column_width=True)
|
|
|
1 |
+
|
2 |
import streamlit as st
|
|
|
3 |
from PIL import Image
|
4 |
import face_recognition
|
5 |
import cv2
|
|
|
59 |
|
60 |
y1, x2, y2, x1 = faceLoc
|
61 |
y1, x2, y2, x1 = (y1 * 4), (x2 * 4), (y2 * 4) ,(x1 * 4)
|
|
|
|
|
|
|
62 |
|
63 |
+
# Make a copy of the image array before drawing on it
|
64 |
+
image_copy = image.copy()
|
65 |
+
|
66 |
+
cv2.rectangle(image_copy, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
67 |
+
cv2.rectangle(image_copy, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
|
68 |
+
cv2.putText(image_copy, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
|
69 |
+
|
70 |
+
st.image(image_copy, use_column_width=True, output_format="PNG")
|
71 |
else:
|
72 |
+
st.warning("No faces detected in the image. Face recognition failed.")
|
73 |
|
74 |
# image = Image.open(file_name)
|
75 |
# col1.image(image, use_column_width=True)
|