-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 batch processing #2978
Vision: Add batch processing #2978
Conversation
"""Batch multiple images into one request.""" | ||
|
||
|
||
class Batch(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
""" | ||
return self._images | ||
|
||
def detect(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -30,24 +30,25 @@ def __init__(self, client=None): | |||
self._client = client | |||
self._annotator_client = image_annotator_client.ImageAnnotatorClient() | |||
|
|||
def annotate(self, image, features): | |||
def annotate(self, images): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/vision-usage.rst
Outdated
********************* | ||
|
||
Multiple images can be processed with a single request by passing ``Image``s to | ||
``Client.batch(images)``. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/vision-usage.rst
Outdated
>>> batch.add_image(image_one, [face_feature, logo_feature]) | ||
>>> batch.add_image(image_two, [logo_feature]) | ||
>>> results = batch.detect() | ||
>>> for face in results[0].faces: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -507,3 +509,53 @@ def test_detect_properties_filename(self): | |||
image = client.image(filename=FACE_FILE) | |||
properties = image.detect_properties() | |||
self._assert_properties(properties) | |||
|
|||
|
|||
class TestVisionBatchProcessing(BaseVisionTestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -30,24 +30,25 @@ def __init__(self, client=None): | |||
self._client = client | |||
self._annotator_client = image_annotator_client.ImageAnnotatorClient() | |||
|
|||
def annotate(self, image, features): | |||
def annotate(self, images): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"""Batch multiple images into one request.""" | ||
|
||
|
||
class Batch(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
vision/google/cloud/vision/client.py
Outdated
@@ -71,6 +72,14 @@ def __init__(self, project=None, credentials=None, http=None, | |||
else: | |||
self._use_gax = use_gax | |||
|
|||
def batch(self): | |||
"""Batch image processing. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I just wanted to check. I think everything was addressed here? |
I would still like to understand why |
@lukesneeringer That said, the signature change is required because multiple images need to be passed to You build multiple Alternatively I could have duplicated the |
Okay, that is fine. |
Ok, I'll merge this in an hour or two. There's some other vision work that I want to get closer to finished before I rebase this into it. |
* Add Vision batch support to the surface.
* Add Vision batch support to the surface.
I wasn't sure the best way to add the context manager to
Batch
since there needs to be a result returned. I'm not sure of a good way to do that from a context manager's__exit__
without attaching the results to something.Closes #2897