Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vision: Add gRPC support for face detection. #2922

Merged
merged 1 commit into from
Jan 19, 2017

Conversation

daspecster
Copy link
Contributor

@daspecster daspecster commented Jan 6, 2017

Based from #2918

This adds gRPC support for face_detect().

@daspecster daspecster added the api: vision Issues related to the Cloud Vision API. label Jan 6, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 6, 2017
@@ -63,7 +63,6 @@ def _assert_coordinate(self, coordinate):
if coordinate is None:
return
self.assertIsInstance(coordinate, (int, float))
self.assertNotEqual(coordinate, 0.0)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -133,6 +132,7 @@ def test_detect_logos_gcs(self):

class TestVisionClientFace(BaseVisionTestCase):
def setUp(self):
Config.CLIENT = vision.Client(use_gax=True)

This comment was marked as spam.

@@ -423,6 +425,7 @@ def _assert_text(self, text):

def test_detect_text_content(self):
client = Config.CLIENT
client._use_gax = True

This comment was marked as spam.

:rtype: :class:`~google.cloud.vision.likelihood.Likelihood`
:returns: Instance of ``Likelihood`` converted from gRPC value.
"""
likelihood_pb = LIKELIHOOD_PB.get(likelihood)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -42,6 +65,23 @@ def from_api_repr(cls, response):

return cls(roll, pan, tilt)

@classmethod
def from_pb(cls, response):

This comment was marked as spam.

def from_pb(cls, response_landmark):
"""Factory: construct an instance of a Landmark from a response.

:type response_landmark: dict

This comment was marked as spam.

"""
landmarks = []
for landmark in response:
landmarks.append(Landmark.from_api_repr(landmark))

This comment was marked as spam.

@@ -54,7 +54,7 @@ def __init__(self, client, content=None, filename=None, source_uri=None):
content = file_obj.read()

if content is not None:
content = _bytes_to_unicode(b64encode(_to_bytes(content)))
content = _to_bytes(content)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -67,7 +67,7 @@ def as_dict(self):
"""
if self.content:
return {
'content': self.content
'content': _bytes_to_unicode(b64encode(self.content))

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -88,6 +88,21 @@ def test_make_entity_from_pb(self):
self.assertEqual(entity.locations[0].longitude, 2.0)


class TestMakeFacesFromPB(unittest.TestCase):

This comment was marked as spam.

@daspecster daspecster force-pushed the vision-add-face-from-pb branch from b5bf40f to 28bc79e Compare January 13, 2017 15:53
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jan 13, 2017
@daspecster daspecster force-pushed the vision-add-face-from-pb branch from 28bc79e to c30955d Compare January 13, 2017 15:54
@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jan 13, 2017
@daspecster daspecster force-pushed the vision-add-face-from-pb branch 2 times, most recently from 732c099 to 46edcc2 Compare January 14, 2017 00:28
@daspecster
Copy link
Contributor Author

Rebased on master.

@daspecster daspecster force-pushed the vision-add-face-from-pb branch 3 times, most recently from b17c58a to 01474cc Compare January 17, 2017 01:02
@daspecster daspecster changed the title Vision add face from pb Vision: Add gRPC support for face detection. Jan 17, 2017
@@ -137,6 +137,7 @@ def test_detect_logos_gcs(self):

class TestVisionClientFace(BaseVisionTestCase):
def setUp(self):
Config.CLIENT = vision.Client()

This comment was marked as spam.

@@ -85,7 +83,7 @@ def _to_gapic_image(image):
:class:`~google.cloud.vision.image.Image`.
"""
if image.content is not None:
return image_annotator_pb2.Image(content=_to_bytes(image.content))
return image_annotator_pb2.Image(content=image.content)

This comment was marked as spam.

This comment was marked as spam.

@@ -58,7 +58,7 @@ class Client(JSONClient):
_vision_api_internal = None

def __init__(self, project=None, credentials=None, http=None,
use_gax=False):
use_gax=None):

This comment was marked as spam.

This comment was marked as spam.

joy_likelihood = Likelihood[emotions['joyLikelihood']]
sorrow_likelihood = Likelihood[emotions['sorrowLikelihood']]
surprise_likelihood = Likelihood[emotions['surpriseLikelihood']]
anger_likelihood = Likelihood[emotions['angerLikelihood']]

This comment was marked as spam.

This comment was marked as spam.

CHIN_LEFT_GONION = 'CHIN_LEFT_GONION'
CHIN_RIGHT_GONION = 'CHIN_RIGHT_GONION'
# Unknown face landmark detected. Should not be filled.
UNKNOWN_LANDMARK = 0

This comment was marked as spam.

@@ -219,7 +231,8 @@ def x_coordinate(self):
:rtype: float
:returns: X position coordinate.
"""
return self._x_coordinate
if self._x_coordinate != 0:
return self._x_coordinate

This comment was marked as spam.

@@ -54,7 +54,7 @@ def __init__(self, client, content=None, filename=None, source_uri=None):
content = file_obj.read()

if content is not None:
content = _bytes_to_unicode(b64encode(_to_bytes(content)))
content = _to_bytes(content)

This comment was marked as spam.

@@ -67,7 +67,7 @@ def as_dict(self):
"""
if self.content:
return {
'content': self.content
'content': _bytes_to_unicode(b64encode(self.content))

This comment was marked as spam.

@@ -73,7 +73,7 @@ def test_from_pb(self):
annotations = self._make_one().from_pb(image_response)
self.assertEqual(annotations.labels, [])
self.assertEqual(annotations.logos, [])
self.assertEqual(annotations.faces, ())
self.assertEqual(annotations.faces, [])

This comment was marked as spam.

This comment was marked as spam.

from google.cloud.vision.annotations import _make_faces_from_pb
return _make_faces_from_pb(annotations)

def test_make_face_from_pb(self):

This comment was marked as spam.

@daspecster daspecster force-pushed the vision-add-face-from-pb branch from ff3f62b to 04517cd Compare January 19, 2017 17:20
@daspecster
Copy link
Contributor Author

daspecster commented Jan 19, 2017

Merging after chat LGTM and Travis went green.

@daspecster daspecster merged commit 309fa8d into googleapis:master Jan 19, 2017
@daspecster daspecster deleted the vision-add-face-from-pb branch January 19, 2017 17:36
@daspecster daspecster mentioned this pull request Jan 31, 2017
10 tasks
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
…om-pb

Vision: Add gRPC support for face detection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vision Issues related to the Cloud Vision API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants