| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Mostly LGTM though ISTM you should be doing
features = [feature]in _detect_annotation
Sorry, something went wrong.
| :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` |
| return self._source | ||
|
|
||
| def _detect_annotation(self, feature): | ||
| def _detect_annotation(self, features): |
| """Convert a JSON result to an entity type based on the feature.""" | ||
|
|
||
| reverse_types = { | ||
| 'FACE_DETECTION': 'faceAnnotations', |
| return detected_objects[0] | ||
| return detected_objects | ||
|
|
||
| @staticmethod |
| self._entity_from_response_type(feature.feature_type, results)) | ||
|
|
||
| if len(detected_objects) == 1: | ||
| return detected_objects[0] |
| result = results[feature_key] | ||
| detected_objects.append(SafeSearchAnnotation.from_api_repr(result)) | ||
| else: | ||
| for result in results[feature_key]: |
| detected_objects.append(detected_object) | ||
| feature_key = reverse_types[feature_type] | ||
|
|
||
| if feature_type == 'FACE_DETECTION': |
|
|
||
| if feature_type == 'FACE_DETECTION': | ||
| for face in results[feature_key]: | ||
| detected_objects.append(Face.from_api_repr(face)) |
| detected_objects.append(SafeSearchAnnotation.from_api_repr(result)) | ||
| else: | ||
| for result in results[feature_key]: | ||
| detected_objects.append(EntityAnnotation.from_api_repr(result)) |
|
Regarding your comment about features = [features], if I do that, then I'll need to put a check there as well. if not isinstance(features, list):
features = [features] |
Sorry, something went wrong.
| 'LOGO_DETECTION': 'logoAnnotations', | ||
| _SAFE_SEARCH_DETECTION: 'safeSearchAnnotation', | ||
| 'TEXT_DETECTION': 'textAnnotations', | ||
| } |
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. |
Sorry, something went wrong.
|
Squished. Once the build goes green I'll merge. |
Sorry, something went wrong.
…quests Refactor _detect_annotation() to support all annotation types.
Refactor _detect_annotation() to support all annotation types.
| Back | FazBrowse Home | New Git URL |
This is a step towards adding the manual detect method.
See: #2697