File tree Expand file tree Collapse file tree 2 files changed +5
-13
lines changed
vision/google/cloud/vision Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def _process_image_annotations(image):
119
119
:returns: Dictionary populated with entities from response.
120
120
"""
121
121
return {
122
+ 'faces' : _make_faces_from_pb (image .face_annotations ),
122
123
'labels' : _make_entity_from_pb (image .label_annotations ),
123
124
'landmarks' : _make_entity_from_pb (image .landmark_annotations ),
124
125
'logos' : _make_entity_from_pb (image .logo_annotations ),
Original file line number Diff line number Diff line change 17
17
18
18
from enum import Enum
19
19
20
+ from google .cloud .grpc .vision .v1 import image_annotator_pb2
21
+
20
22
from google .cloud .vision .geometry import BoundsBase
21
23
from google .cloud .vision .likelihood import Likelihood
22
24
from google .cloud .vision .geometry import Position
23
25
24
26
25
- LIKELIHOOD_PB = {
26
- 0 : 'UNKNOWN' ,
27
- 1 : 'VERY_UNLIKELY' ,
28
- 2 : 'UNLIKELY' ,
29
- 3 : 'POSSIBLE' ,
30
- 4 : 'LIKELY' ,
31
- 5 : 'VERY_LIKELY' ,
32
- }
33
-
34
-
35
27
def _get_pb_likelihood (likelihood ):
36
28
"""Convert gRPC Likelihood integer value to Likelihood instance.
37
29
@@ -41,7 +33,7 @@ def _get_pb_likelihood(likelihood):
41
33
:rtype: :class:`~google.cloud.vision.likelihood.Likelihood`
42
34
:returns: Instance of ``Likelihood`` converted from gRPC value.
43
35
"""
44
- likelihood_pb = LIKELIHOOD_PB . get (likelihood )
36
+ likelihood_pb = image_annotator_pb2 . Likelihood . Name (likelihood )
45
37
return Likelihood [likelihood_pb ]
46
38
47
39
@@ -256,8 +248,7 @@ def from_pb(cls, response):
256
248
detection_confidence = response .detection_confidence
257
249
emotions = Emotions .from_pb (response )
258
250
fd_bounds = FDBounds .from_pb (response .fd_bounding_poly )
259
- headwear_likelihood = Likelihood [
260
- LIKELIHOOD_PB [response .headwear_likelihood ]]
251
+ headwear_likelihood = _get_pb_likelihood (response .headwear_likelihood )
261
252
image_properties = FaceImageProperties .from_pb (response )
262
253
landmarks = Landmarks .from_pb (response .landmarks )
263
254
landmarking_confidence = response .landmarking_confidence
You can’t perform that action at this time.
0 commit comments