Uh oh!
There was an error while loading. Please reload this page.
Refactor _detect_annotation() to support all annotation types. - #2712
Conversation
51433d6 to
7d4a998Compare7d4a998 to
e766ac9Compare
dhermes
left a comment
There was a problem hiding this comment.
Mostly LGTM though ISTM you should be doing
features= [feature]in _detect_annotation
| :type feature: :class:`~google.cloud.vision.feature.Feature` | ||
| :param feature: The ``Feature`` indication the type of annotation to | ||
| perform. | ||
| :type features: list of:class:`~google.cloud.vision.feature.Feature` |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return self._source | ||
| def _detect_annotation(self, feature): | ||
| def _detect_annotation(self, features): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| """Convert a JSON result to an entity type based on the feature.""" | ||
| reverse_types = { | ||
| 'FACE_DETECTION': 'faceAnnotations', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return detected_objects[0] | ||
| return detected_objects | ||
| @staticmethod |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self._entity_from_response_type(feature.feature_type, results)) | ||
| if len(detected_objects) == 1: | ||
| return detected_objects[0] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| result = results[feature_key] | ||
| detected_objects.append(SafeSearchAnnotation.from_api_repr(result)) | ||
| else: | ||
| for result in results[feature_key]: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| detected_objects.append(detected_object) | ||
| feature_key = reverse_types[feature_type] | ||
| if feature_type == 'FACE_DETECTION': |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| if feature_type == 'FACE_DETECTION': | ||
| for face in results[feature_key]: | ||
| detected_objects.append(Face.from_api_repr(face)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| detected_objects.append(SafeSearchAnnotation.from_api_repr(result)) | ||
| else: | ||
| for result in results[feature_key]: | ||
| detected_objects.append(EntityAnnotation.from_api_repr(result)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daspecster
commented
Nov 11, 2016
Regarding your comment about ifnotisinstance(features, list):
features= [features] |
| 'LOGO_DETECTION': 'logoAnnotations', | ||
| _SAFE_SEARCH_DETECTION: 'safeSearchAnnotation', | ||
| 'TEXT_DETECTION': 'textAnnotations', | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dhermes
commented
Nov 11, 2016
No, just make your callers obey the signature. So if it accepts one feature (which all the current callers so) then they send one feature. However, as I mentioned before, just leave the change in. |
daspecster
commented
Nov 11, 2016
1bfd25f to
f164c3fComparedaspecster
commented
Nov 11, 2016
Squished. Once the build goes green I'll merge. |
f164c3f to
83b128aCompare…quests Refactor _detect_annotation() to support all annotation types.
Refactor _detect_annotation() to support all annotation types.
This is a step towards adding the manual detect method.
See: #2697