I am working with Google cloud vision API with Python
(https://googlecloudplatform.github.io/google-cloud-python/stable/vision-usage.html)
But I could not understand why the annotation result of a single image consists of list
of annotation
s.
The document says:
>>> from google.cloud import vision
>>> from google.cloud.vision.feature import Feature
>>> from google.cloud.vision.feature import FeatureTypes
>>> client = vision.Client()
>>> image = client.image(source_uri='gs://my-test-bucket/image.jpg')
>>> features = [Feature(FeatureTypes.FACE_DETECTION, 5),
... Feature(FeatureTypes.LOGO_DETECTION, 3)]
>>> annotations = image.detect(features)
>>> len(annotations)
2
>>> for face in annotations[0].faces:
... print(face.joy)
Likelihood.VERY_LIKELY
Likelihood.VERY_LIKELY
Likelihood.VERY_LIKELY
>>> for logo in annotations[0].logos:
... print(logo.description)
'google'
'github'
Why image.detect
returns multiple annotations for a single image?
It seems unnecessary because detection results are contained in each attributes (annotations[0].faces
, annotations[0].logos
, etc.).
And when I try the api with my own image it returns the annotations
of length 1.
So my question is:
- Why python's vision api client returns multiple annotations for a single image?
- Do I need to parse every
annotation
in the listannotations
?