Kdorlette
fixed input image bug
de89825
raw
history blame
1.24 kB
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)
st.write("I found {} face(s) in this photograph.".format(len(face_locations)))
for face_location in face_locations:
# Print the location of each face in this image
top, right, bottom, left = face_location
st.write("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
# 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)
else:
st.write("Please upload an image to proceed.")