def visualize()

in source/simulate/face_compare.py [0:0]


    def visualize(image_1, image_2, response):
        fig, (ax1, ax2) = plt.subplots(2, 1)
        source_face_bbox = response['SourceImageFace']['BoundingBox']
        source_face_confidence = response['SourceImageFace']['Confidence']
        source_face_keypoints = response['SourceImageFace']['KeyPoints']

        source_eye_left = source_face_keypoints['eyeLeft']
        source_eye_right = source_face_keypoints['eyeRight']
        source_mouth_left = source_face_keypoints['mouthLeft']
        source_mouth_right = source_face_keypoints['mouthRight']
        source_nose = source_face_keypoints['nose']

        ax1.plot(source_eye_left[0], source_eye_left[1], 'r.')
        ax1.plot(source_eye_right[0], source_eye_right[1], 'b.')
        ax1.plot(source_nose[0], source_nose[1], 'g.')
        ax1.plot(source_mouth_left[0], source_mouth_left[1], 'k.')
        ax1.plot(source_mouth_right[0], source_mouth_right[1], 'y.')

        ax1.imshow(image_1[:, :, ::-1])
        rect = patches.Rectangle((source_face_bbox[0], source_face_bbox[1]),
                                 source_face_bbox[2] - source_face_bbox[0],
                                 source_face_bbox[3] - source_face_bbox[1], linewidth=1, edgecolor='r',
                                 facecolor='none')
        ax1.add_patch(rect)
        ax1.text(source_face_bbox[0], source_face_bbox[1],
                 'confidence = {}'.format(round(source_face_confidence, 2)), color='red', fontsize=8)

        ax2.imshow(image_2[:, :, ::-1])

        face_matches = response['FaceMatches']
        for match_face in face_matches:
            similarity_score = match_face['Similarity']
            face_bbox = match_face['Face']['BoundingBox']
            face_confidence = match_face['Face']['Confidence']
            face_keypoints = match_face['Face']['KeyPoints']

            eye_left = face_keypoints['eyeLeft']
            eye_right = face_keypoints['eyeRight']
            mouth_left = face_keypoints['mouthLeft']
            mouth_right = face_keypoints['mouthRight']
            nose = face_keypoints['nose']

            ax2.plot(eye_left[0], eye_left[1], 'r.')
            ax2.plot(eye_right[0], eye_right[1], 'b.')
            ax2.plot(nose[0], nose[1], 'g.')
            ax2.plot(mouth_left[0], mouth_left[1], 'k.')
            ax2.plot(mouth_right[0], mouth_right[1], 'y.')

            ax2.imshow(image_2[:, :, ::-1])
            rect = patches.Rectangle((face_bbox[0], face_bbox[1]), face_bbox[2] - face_bbox[0],
                                     face_bbox[3] - face_bbox[1], linewidth=1, edgecolor='r',
                                     facecolor='none')
            ax2.add_patch(rect)
            ax2.text(face_bbox[0], face_bbox[1], 'confidence = {}'.format(round(face_confidence, 2)),
                     color='red', fontsize=8)
            ax2.text(face_bbox[2], face_bbox[3], 'similarity = {}'.format(round(similarity_score, 2)),
                     color='blue', fontsize=8)

        plt.show()