Skip to content

Add image.detect() for detecting multiple types. - #2770

Merged
daspecster merged 3 commits into
googleapis:masterfrom
daspecster:add-manual-detect-to-vision-2697
Nov 30, 2016
Merged

Add image.detect() for detecting multiple types.#2770
daspecster merged 3 commits into
googleapis:masterfrom
daspecster:add-manual-detect-to-vision-2697

Conversation

@daspecster

@daspecsterdaspecster commented Nov 24, 2016

Copy link
Copy Markdown
Contributor

Closes#2697, #2769

@daspecsterdaspecster added the api: vision Issues related to the Cloud Vision API. label Nov 24, 2016
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 24, 2016
@daspecster
daspecsterforce-pushed the add-manual-detect-to-vision-2697 branch from 5c6485d to 74eef27CompareNovember 24, 2016 16:06
@daspecsterdaspecster mentioned this pull request Nov 28, 2016
10 tasks
@daspecster

Copy link
Copy Markdown
ContributorAuthor

Bumpidy bump bump.

Comment threaddocs/vision-annotations.rst Outdated
==================

Image Annotations
~~~~~~~~~~~~~~~~~

This comment was marked as spam.

Comment threadvision/unit_tests/test_client.py Outdated
self.assertEqual(items.labels[2].description, 'truck')
self.assertEqual(items.labels[2].score, 0.88429511)

image_request = client._connection._requested[0]['data']['requests'][0]

This comment was marked as spam.

Comment threadvision/unit_tests/test_client.py Outdated
from google.cloud.vision.feature import FeatureTypes
from unit_tests._fixtures import LABEL_DETECTION_RESPONSE
from unit_tests._fixtures import LOGO_DETECTION_RESPONSE
RETURNED = LABEL_DETECTION_RESPONSE

This comment was marked as spam.

Comment threadvision/unit_tests/test_client.py Outdated
from unit_tests._fixtures import LOGO_DETECTION_RESPONSE
RETURNED = LABEL_DETECTION_RESPONSE
LOGOS = LOGO_DETECTION_RESPONSE['responses'][0]['logoAnnotations']
RETURNED['responses'][0]['logoAnnotations'] = LOGOS

This comment was marked as spam.

from google.cloud.vision.entity import EntityAnnotation
from google.cloud.vision.face import Face
from google.cloud.vision.feature import FeatureTypes
from google.cloud.vision.color import ImagePropertiesAnnotation

This comment was marked as spam.


for feature_type, annotation in response.items():
annotations[feature_type].extend(
_entity_from_response_type(feature_type, annotation))

This comment was marked as spam.

texts = annotations.get(
_REVERSE_TYPES[FeatureTypes.TEXT_DETECTION], [])

return cls(faces=faces, properties=properties, labels=labels,

This comment was marked as spam.


def _entity_from_response_type(feature_type, results):
"""Convert a JSON result to an entity type based on the feature."""

This comment was marked as spam.



def _entity_from_response_type(feature_type, results):
"""Convert a JSON result to an entity type based on the feature."""

This comment was marked as spam.

"""Convert a JSON result to an entity type based on the feature."""

detected_objects = []
if feature_type == _REVERSE_TYPES[FeatureTypes.FACE_DETECTION]:

This comment was marked as spam.

@daspecster

Copy link
Copy Markdown
ContributorAuthor

Great feedback!

I was able to remove a good chunk of code from your suggestions.

@daspecster
daspecsterforce-pushed the add-manual-detect-to-vision-2697 branch from 2da9e85 to a720bffCompareNovember 29, 2016 21:29
@daspecster

Copy link
Copy Markdown
ContributorAuthor

Rebased to get rid of the conflict.

"""
def __init__(self, faces=None, properties=None, labels=None,
landmarks=None, logos=None, safe_searches=None, texts=None):
self.faces = faces or ()

This comment was marked as spam.

'logoAnnotations': 'logos',
'safeSearchAnnotation': 'safe_searches',
'textAnnotations': 'texts'
}

This comment was marked as spam.

:class:`~google.cloud.vision.safe.SafeSearchAnnotation`.
"""
detected_objects = []
if feature_type == 'faceAnnotations':

This comment was marked as spam.

IMAGE_PROPERTIES_ANNOTATION = 'imagePropertiesAnnotation'
SAFE_SEARCH_ANNOTATION = 'safeSearchAnnotation'

KEY_MAP = {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@dhermesdhermes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after nit

…ant, make duplicated response keys constants.
@daspecster
daspecsterforce-pushed the add-manual-detect-to-vision-2697 branch from ec99e2f to 52aaf05CompareNovember 30, 2016 03:14
@daspecster

Copy link
Copy Markdown
ContributorAuthor

Travis went green so I'm merging.

@daspecster
daspecster merged commit 5cbbcb9 into googleapis:masterNov 30, 2016
@daspecster
daspecster deleted the add-manual-detect-to-vision-2697 branch November 30, 2016 03:31

FACE_ANNOTATIONS = 'faceAnnotations'
IMAGE_PROPERTIES_ANNOTATION = 'imagePropertiesAnnotation'
SAFE_SEARCH_ANNOTATION = 'safeSearchAnnotation'

This comment was marked as spam.

This comment was marked as spam.

richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
…to-vision-2697
Add image.detect() for detecting multiple types.
parthea pushed a commit that referenced this pull request Oct 21, 2023
…2697
Add image.detect() for detecting multiple types.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: visionIssues related to the Cloud Vision API.cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@daspecster@dhermes@tseaver@googlebot