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):
119119 :returns: Dictionary populated with entities from response.
120120 """
121121 return {
122+ 'faces' : _make_faces_from_pb (image .face_annotations ),
122123 'labels' : _make_entity_from_pb (image .label_annotations ),
123124 'landmarks' : _make_entity_from_pb (image .landmark_annotations ),
124125 'logos' : _make_entity_from_pb (image .logo_annotations ),
Original file line number Diff line number Diff line change 1717
1818from enum import Enum
1919
20+ from google .cloud .grpc .vision .v1 import image_annotator_pb2
21+
2022from google .cloud .vision .geometry import BoundsBase
2123from google .cloud .vision .likelihood import Likelihood
2224from google .cloud .vision .geometry import Position
2325
2426
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-
3527def _get_pb_likelihood (likelihood ):
3628 """Convert gRPC Likelihood integer value to Likelihood instance.
3729
@@ -41,7 +33,7 @@ def _get_pb_likelihood(likelihood):
4133 :rtype: :class:`~google.cloud.vision.likelihood.Likelihood`
4234 :returns: Instance of ``Likelihood`` converted from gRPC value.
4335 """
44- likelihood_pb = LIKELIHOOD_PB . get (likelihood )
36+ likelihood_pb = image_annotator_pb2 . Likelihood . Name (likelihood )
4537 return Likelihood [likelihood_pb ]
4638
4739
@@ -256,8 +248,7 @@ def from_pb(cls, response):
256248 detection_confidence = response .detection_confidence
257249 emotions = Emotions .from_pb (response )
258250 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 )
261252 image_properties = FaceImageProperties .from_pb (response )
262253 landmarks = Landmarks .from_pb (response .landmarks )
263254 landmarking_confidence = response .landmarking_confidence
You can’t perform that action at this time.
0 commit comments