Spaces:
Running
Running
Update demo.py
Browse files
demo.py
CHANGED
|
@@ -4,22 +4,24 @@ import datadog_api_client
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
def face_crop(image, face_rect):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
if
|
| 16 |
-
|
| 17 |
-
if
|
| 18 |
-
|
| 19 |
-
if
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
face_image_ratio = face_image.width / float(face_image.height)
|
| 24 |
resized_w = int(face_image_ratio * 150)
|
| 25 |
resized_h = 150
|
|
@@ -94,13 +96,12 @@ with gr.Blocks(css=".gradio-container {background-color: #F4E5E0}") as demo:
|
|
| 94 |
with gr.Row():
|
| 95 |
with gr.Column():
|
| 96 |
image_input1 = gr.Image(type='pil')
|
| 97 |
-
gr.Examples(['
|
| 98 |
inputs=image_input1)
|
| 99 |
with gr.Column():
|
| 100 |
image_input2 = gr.Image(type='pil')
|
| 101 |
-
gr.Examples(['
|
| 102 |
inputs=image_input2)
|
| 103 |
-
verifyThreshold = gr.Slider(minimum=0, maximum=1, value=0.67, label="Verify Threshold")
|
| 104 |
face_recog_button = gr.Button("Face Recognition")
|
| 105 |
with gr.Column(scale=3):
|
| 106 |
recog_html_output = gr.HTML()
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
def face_crop(image, face_rect):
|
| 7 |
+
x1 = face_rect.get('x1')
|
| 8 |
+
y1 = face_rect.get('y1')
|
| 9 |
+
x2 = face_rect.get('x2')
|
| 10 |
+
y2 = face_rect.get('y2')
|
| 11 |
+
width = x2 - x1 + 1
|
| 12 |
+
height = y2 - y2 + 1
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
if x1 < 0:
|
| 16 |
+
x1 = 0
|
| 17 |
+
if y1 < 0:
|
| 18 |
+
y1 = 0
|
| 19 |
+
if x2 >= image.width:
|
| 20 |
+
x2 = image.width - 1
|
| 21 |
+
if y2 >= image.height:
|
| 22 |
+
y2 = image.height - 1
|
| 23 |
+
|
| 24 |
+
face_image = image.crop((x1, y1, x2, y2))
|
| 25 |
face_image_ratio = face_image.width / float(face_image.height)
|
| 26 |
resized_w = int(face_image_ratio * 150)
|
| 27 |
resized_h = 150
|
|
|
|
| 96 |
with gr.Row():
|
| 97 |
with gr.Column():
|
| 98 |
image_input1 = gr.Image(type='pil')
|
| 99 |
+
gr.Examples(['face_examples/1.jpg', 'face_examples/3.jpg', 'face_examples/7.jpg', 'face_examples/9.jpg'],
|
| 100 |
inputs=image_input1)
|
| 101 |
with gr.Column():
|
| 102 |
image_input2 = gr.Image(type='pil')
|
| 103 |
+
gr.Examples(['face_examples/2.jpg', 'face_examples/4.jpg', 'face_examples/8.jpg', 'face_examples/10.jpg'],
|
| 104 |
inputs=image_input2)
|
|
|
|
| 105 |
face_recog_button = gr.Button("Face Recognition")
|
| 106 |
with gr.Column(scale=3):
|
| 107 |
recog_html_output = gr.HTML()
|