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']

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' ]
uses the vision api to detect faces in the given file .