(face_file, max_results=4)
return response['responses'][0]['faceAnnotations']
Uses the Vision API to detect faces in the given file.

    Args:
        face_file: A file-like object containing an image with faces.

    Returns:
        An array of dicts with information about the faces in the picture.
Uses the Vision API to detect faces in the given file.
Uses the Vision API to detect faces in the given file .
def detect_face(face_file, max_results=4):
    """Uses the Vision API to detect faces in the given file.

    Args:
        face_file: A file-like object containing an image with faces.

    Returns:
        An array of dicts with information about the faces in the picture.
    """
    image_content = face_file.read()
    batch_request = [{
        'image': {
            'content': base64.b64encode(image_content).decode('utf-8')
        },
        'features': [{
            'type': 'FACE_DETECTION',
            'maxResults': max_results,
        }]
    }]

    service = get_vision_service()
    request = service.images().annotate(body={
        'requests': batch_request,
    })
    response = request.execute()

    return response['responses'][0]['faceAnnotations']
def detect_face ( face_file , max_results = 4 ) : image_content = face_file . read ( ) batch_request = [ { 'image' : { 'content' : base64 . b64encode ( image_content ) . decode ( 'utf-8' ) } , 'features' : [ { 'type' : 'FACE_DETECTION' , 'maxResults' : max_results , } ] } ] service = get_vision_service ( ) request = service . images ( ) . annotate ( body = { 'requests' : batch_request , } ) response = request . execute ( ) return response [ 'responses' ] [ 0 ] [ 'faceAnnotations' ]