I'm attempting to use the Cloud Vision API client to detect 'labels' and faces in an image.
I can detect labels like this with the key line of code being:
response = client.label_detection(image=image)
labels = response.label_annotations
and for detecting faces:
response = client.face_detection(image=image)
faces = response.face_annotations
So, currently I can make two API calls to get the information I need but I'd like to combine them into one API call if possible.
Update:
I found the annotate_image()
method that can accept a list of features on this page:
response = client.annotate_image({
'image': {'source': {'image_uri': 'gs://my-test-bucket/image.jpg'}},
'features': [{'type': vision.enums.Feature.Type.FACE_DETECTION}],
})
But the image source only accepts a URL to the image or its path on Google Cloud. I want to run analysis on images that I have stored locally, is this possible?