Spaces:
Paused
Paused
Delete hivisionai/hycv/mtcnn_onnx/visualization_utils.py
Browse files
hivisionai/hycv/mtcnn_onnx/visualization_utils.py
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
from PIL import ImageDraw
|
2 |
-
|
3 |
-
|
4 |
-
def show_bboxes(img, bounding_boxes, facial_landmarks=[]):
|
5 |
-
"""Draw bounding boxes and facial landmarks.
|
6 |
-
|
7 |
-
Arguments:
|
8 |
-
img: an instance of PIL.Image.
|
9 |
-
bounding_boxes: a float numpy array of shape [n, 5].
|
10 |
-
facial_landmarks: a float numpy array of shape [n, 10].
|
11 |
-
|
12 |
-
Returns:
|
13 |
-
an instance of PIL.Image.
|
14 |
-
"""
|
15 |
-
|
16 |
-
img_copy = img.copy()
|
17 |
-
draw = ImageDraw.Draw(img_copy)
|
18 |
-
|
19 |
-
for b in bounding_boxes:
|
20 |
-
draw.rectangle([
|
21 |
-
(b[0], b[1]), (b[2], b[3])
|
22 |
-
], outline='white')
|
23 |
-
|
24 |
-
for p in facial_landmarks:
|
25 |
-
for i in range(5):
|
26 |
-
draw.ellipse([
|
27 |
-
(p[i] - 1.0, p[i + 5] - 1.0),
|
28 |
-
(p[i] + 1.0, p[i + 5] + 1.0)
|
29 |
-
], outline='blue')
|
30 |
-
|
31 |
-
return img_copy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|