File tree 1 file changed +6
-8
lines changed
vision/google/cloud/vision
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 14
14
15
15
"""Annotations management for Vision API responses."""
16
16
17
+ import six
17
18
18
19
from google .cloud .vision .color import ImagePropertiesAnnotation
19
20
from google .cloud .vision .entity import EntityAnnotation
@@ -86,14 +87,11 @@ def from_api_repr(cls, response):
86
87
:rtype: :class:`~google.cloud.vision.annotations.Annotations`
87
88
:returns: An instance of ``Annotations`` with detection types loaded.
88
89
"""
89
- annotations = {}
90
- for feature_type , annotation in response .items ():
91
- curr_feature = annotations .setdefault (_KEY_MAP [feature_type ], [])
92
- entity = _entity_from_response_type (feature_type , annotation )
93
- if isinstance (entity , list ):
94
- curr_feature .extend (entity )
95
- else :
96
- annotations [_KEY_MAP [feature_type ]] = entity
90
+ annotations = {
91
+ _KEY_MAP [feature_type ]: _entity_from_response_type (
92
+ feature_type , annotation )
93
+ for feature_type , annotation in six .iteritems (response )
94
+ }
97
95
return cls (** annotations )
98
96
99
97
@classmethod
You can’t perform that action at this time.
0 commit comments