I have a Python(2.7) script which detects faces in an image which works fine.
from PIL import Image
import face_recognition
# Load the jpg file into a numpy array
image = face_recognition.load_image_file("/PATH_TO_IMAGE/IMAGE.jpg")
# Find all the faces in the image
face_locations = face_recognition.face_locations(image)
# a = print("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
print("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)
pil_image.show()
Now, I want to make it as a http://localhost:8080/detect so that user can provide an image and clicking on Submit button will display the output. I think there are few ways to do this, either using Flask, Django or Web server. But not sure which is the simplest way to do this and how to go about it. How to take this code and convert into a webservice? What code changes are required? Any code sample will be of great help.