Uh oh!
There was an error while loading. Please reload this page.
Add image.detect() for detecting multiple types. - #2770
Conversation
5c6485d to
74eef27Comparedaspecster
commented
Nov 29, 2016
Bumpidy bump bump. |
| ================== | ||
| Image Annotations | ||
| ~~~~~~~~~~~~~~~~~ |
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.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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| for feature_type, annotation in response.items(): | ||
| annotations[feature_type].extend( | ||
| _entity_from_response_type(feature_type, annotation)) |
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.
| texts = annotations.get( | ||
| _REVERSE_TYPES[FeatureTypes.TEXT_DETECTION], []) | ||
| return cls(faces=faces, properties=properties, labels=labels, |
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.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
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.""" | ||
| detected_objects = [] | ||
| if feature_type == _REVERSE_TYPES[FeatureTypes.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.
daspecster
commented
Nov 29, 2016
Great feedback! I was able to remove a good chunk of code from your suggestions. |
2da9e85 to
a720bffComparedaspecster
commented
Nov 29, 2016
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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 'logoAnnotations': 'logos', | ||
| 'safeSearchAnnotation': 'safe_searches', | ||
| 'textAnnotations': 'texts' | ||
| } |
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.
| :class:`~google.cloud.vision.safe.SafeSearchAnnotation`. | ||
| """ | ||
| detected_objects = [] | ||
| if feature_type == '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.
| IMAGE_PROPERTIES_ANNOTATION = 'imagePropertiesAnnotation' | ||
| SAFE_SEARCH_ANNOTATION = 'safeSearchAnnotation' | ||
| KEY_MAP = { |
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.
…ant, make duplicated response keys constants.
ec99e2f to
52aaf05Comparedaspecster
commented
Nov 30, 2016
Travis went green so I'm merging. |
| FACE_ANNOTATIONS = 'faceAnnotations' | ||
| IMAGE_PROPERTIES_ANNOTATION = 'imagePropertiesAnnotation' | ||
| SAFE_SEARCH_ANNOTATION = 'safeSearchAnnotation' |
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.
…to-vision-2697 Add image.detect() for detecting multiple types.
…2697 Add image.detect() for detecting multiple types.
Closes#2697, #2769