Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from PIL import Image
|
2 |
import numpy as np
|
3 |
import cv2
|
@@ -6,8 +7,10 @@ import face_recognition
|
|
6 |
import os
|
7 |
import streamlit as st
|
8 |
|
|
|
9 |
p1 = "sarwan.jpg"
|
10 |
p2 = "rattantata.png"
|
|
|
11 |
|
12 |
st.title("Face Recognition ")
|
13 |
Images = []
|
@@ -22,12 +25,17 @@ img2 = cv2.imread(p2)
|
|
22 |
Images.append(img2)
|
23 |
classnames.append("Rattan Tata")
|
24 |
|
|
|
|
|
|
|
|
|
25 |
# Load images for face recognition
|
26 |
encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
|
27 |
|
28 |
-
|
|
|
29 |
# Take picture using the camera
|
30 |
-
img_file_buffer = st.camera_input("Take
|
31 |
|
32 |
# recognise the face in the uploaded image
|
33 |
if img_file_buffer is not None:
|
@@ -49,7 +57,7 @@ if img_file_buffer is not None:
|
|
49 |
|
50 |
if matches[matchIndex]:
|
51 |
name = classnames[matchIndex].upper()
|
52 |
-
st.write (name)
|
53 |
# show the name on image to user
|
54 |
y1, x2, y2, x1 = faceLoc
|
55 |
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
|
@@ -59,8 +67,7 @@ if img_file_buffer is not None:
|
|
59 |
|
60 |
faceMatchedflag = 1
|
61 |
|
62 |
-
st.image(image , use_column_width=True, output_format="PNG")
|
63 |
-
|
64 |
|
65 |
if(faceMatchedflag == 0) :
|
66 |
st.warning("No faces detected in the image.")
|
|
|
1 |
+
####### Section 1 ###################
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
import cv2
|
|
|
7 |
import os
|
8 |
import streamlit as st
|
9 |
|
10 |
+
####### Section 2 ###################
|
11 |
p1 = "sarwan.jpg"
|
12 |
p2 = "rattantata.png"
|
13 |
+
p3 = "Ravinder.jpg"
|
14 |
|
15 |
st.title("Face Recognition ")
|
16 |
Images = []
|
|
|
25 |
Images.append(img2)
|
26 |
classnames.append("Rattan Tata")
|
27 |
|
28 |
+
img3 = cv2.imread(p3)
|
29 |
+
Images.append(img3)
|
30 |
+
classnames.append("Ravinder kaur")
|
31 |
+
|
32 |
# Load images for face recognition
|
33 |
encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
|
34 |
|
35 |
+
|
36 |
+
####### Section 3 ###################
|
37 |
# Take picture using the camera
|
38 |
+
img_file_buffer = st.camera_input("Take Your picture")
|
39 |
|
40 |
# recognise the face in the uploaded image
|
41 |
if img_file_buffer is not None:
|
|
|
57 |
|
58 |
if matches[matchIndex]:
|
59 |
name = classnames[matchIndex].upper()
|
60 |
+
#st.write (name)
|
61 |
# show the name on image to user
|
62 |
y1, x2, y2, x1 = faceLoc
|
63 |
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
|
|
|
67 |
|
68 |
faceMatchedflag = 1
|
69 |
|
70 |
+
st.image(image , use_column_width=True, output_format="PNG")
|
|
|
71 |
|
72 |
if(faceMatchedflag == 0) :
|
73 |
st.warning("No faces detected in the image.")
|