Path: blob/master/Face-Recognition-with-ArcFace/align/visualization_utils.py
3142 views
from PIL import ImageDraw123def show_results(img, bounding_boxes, facial_landmarks = []):4"""Draw bounding boxes and facial landmarks.5Arguments:6img: an instance of PIL.Image.7bounding_boxes: a float numpy array of shape [n, 5].8facial_landmarks: a float numpy array of shape [n, 10].9Returns:10an instance of PIL.Image.11"""12img_copy = img.copy()13draw = ImageDraw.Draw(img_copy)1415for b in bounding_boxes:16draw.rectangle([17(b[0], b[1]), (b[2], b[3])18], outline = 'white')1920inx = 021for p in facial_landmarks:22for i in range(5):23draw.ellipse([24(p[i] - 1.0, p[i + 5] - 1.0),25(p[i] + 1.0, p[i + 5] + 1.0)26], outline = 'blue')2728return img_copy2930