Python で Google クラウド ビジョン API を使用しています
( https://googlecloudplatform.github.io/google-cloud-python/stable/vision-usage.html )
list
しかし、単一の画像のアノテーション結果がsで構成されている理由がわかりませんでしたannotation
。ドキュメントには次
のように記載されています。
>>> 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'
image.detect
1 つの画像に対して複数の注釈が返されるのはなぜですか?
検出結果は各属性( 、 など)に含まれているので不要に思えannotations[0].faces
ますannotations[0].logos
。
そして、自分のイメージで API を試すと、annotations
長さ 1 の が返されます。
だから私の質問は:
- Python の Vision API クライアントが単一の画像に対して複数の注釈を返すのはなぜですか?
annotation
リスト内のすべてを解析する必要がありますannotations
か?