Spaces:
Runtime error
Runtime error
File size: 1,479 Bytes
ed12c4e 9509cf4 938dd1c ed12c4e 938dd1c 9509cf4 938dd1c de89825 9509cf4 de89825 641a529 de89825 da5b3f8 4539d16 da5b3f8 e381c05 da5b3f8 641a529 de89825 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import streamlit as st
from PIL import Image
import face_recognition
st.title("Face Detection")
# Load the jpg file into a numpy array
input_image = st.file_uploader("Upload a candidate image",type=['jpg','png','jpeg'],accept_multiple_files=False)
if input_image is not None:
image = face_recognition.load_image_file(input_image)
st.image(image)
# Find all the faces in the image using the default HOG-based model.
# This method is fairly accurate, but not as accurate as the CNN model and not GPU accelerated.
# See also: find_faces_in_picture_cnn.py
face_locations = face_recognition.face_locations(image)
data_base = []
st.write("I found {} face(s) in this photograph.".format(len(face_locations)))
cols= st.columns(len(face_locations))
for i in range(len(face_locations)):
col = cols[i]
face = face_locations[i]
# display faces
with col:
st.header("Face {}".format(i))
# Print the location of each face in this image
top, right, bottom, left = face
# You can access the actual face itself like this:
face_image = image[top:bottom, left:right]
pil_image = Image.fromarray(face_image)
st.image(pil_image)
face_name = st.text_input('Specify name', "This is a placeholder")
st.write(face_name)
data_base.append(face_name)
else:
st.write("Please upload an image to proceed.")
|