Created
May 13, 2019 15:05
-
-
Save OlafenwaMoses/ab6a655c6fa146686ea55647a4bd0a1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from PIL import Image | |
image_data = open("family.jpg","rb").read() | |
image = Image.open("family.jpg").convert("RGB") | |
response = requests.post("http://localhost:80/v1/vision/face",files={"image":image_data}).json() | |
i = 0 | |
for face in response["predictions"]: | |
y_max = int(face["y_max"]) | |
y_min = int(face["y_min"]) | |
x_max = int(face["x_max"]) | |
x_min = int(face["x_min"]) | |
cropped = image.crop((x_min,y_min,x_max,y_max)) | |
cropped.save("image{}.jpg".format(i)) | |
i += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment