| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Bumpidy bump bump. |
Sorry, something went wrong.
| ================== | ||
|
|
||
| Image Annotations | ||
| ~~~~~~~~~~~~~~~~~ |
| self.assertEqual(items.labels[2].description, 'truck') | ||
| self.assertEqual(items.labels[2].score, 0.88429511) | ||
|
|
||
| image_request = client._connection._requested[0]['data']['requests'][0] |
| 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 |
| from unit_tests._fixtures import LOGO_DETECTION_RESPONSE | ||
| RETURNED = LABEL_DETECTION_RESPONSE | ||
| LOGOS = LOGO_DETECTION_RESPONSE['responses'][0]['logoAnnotations'] | ||
| RETURNED['responses'][0]['logoAnnotations'] = LOGOS |
| 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 |
|
|
||
| for feature_type, annotation in response.items(): | ||
| annotations[feature_type].extend( | ||
| _entity_from_response_type(feature_type, annotation)) |
| texts = annotations.get( | ||
| _REVERSE_TYPES[FeatureTypes.TEXT_DETECTION], []) | ||
|
|
||
| return cls(faces=faces, properties=properties, labels=labels, |
|
|
||
| def _entity_from_response_type(feature_type, results): | ||
| """Convert a JSON result to an entity type based on the feature.""" | ||
|
|
|
|
||
|
|
||
| def _entity_from_response_type(feature_type, results): | ||
| """Convert a JSON result to an entity type based on the feature.""" |
| """Convert a JSON result to an entity type based on the feature.""" | ||
|
|
||
| detected_objects = [] | ||
| if feature_type == _REVERSE_TYPES[FeatureTypes.FACE_DETECTION]: |
|
Great feedback! I was able to remove a good chunk of code from your suggestions. |
Sorry, something went wrong.
|
Rebased to get rid of the conflict. |
Sorry, something went wrong.
| """ | ||
| def __init__(self, faces=None, properties=None, labels=None, | ||
| landmarks=None, logos=None, safe_searches=None, texts=None): | ||
| self.faces = faces or () |
| 'logoAnnotations': 'logos', | ||
| 'safeSearchAnnotation': 'safe_searches', | ||
| 'textAnnotations': 'texts' | ||
| } |
| :class:`~google.cloud.vision.safe.SafeSearchAnnotation`. | ||
| """ | ||
| detected_objects = [] | ||
| if feature_type == 'faceAnnotations': |
| IMAGE_PROPERTIES_ANNOTATION = 'imagePropertiesAnnotation' | ||
| SAFE_SEARCH_ANNOTATION = 'safeSearchAnnotation' | ||
|
|
||
| KEY_MAP = { |
There was a problem hiding this comment.
LGTM after nit
Sorry, something went wrong.
…ant, make duplicated response keys constants.
|
Travis went green so I'm merging. |
Sorry, something went wrong.
|
|
||
| FACE_ANNOTATIONS = 'faceAnnotations' | ||
| IMAGE_PROPERTIES_ANNOTATION = 'imagePropertiesAnnotation' | ||
| SAFE_SEARCH_ANNOTATION = 'safeSearchAnnotation' |
…to-vision-2697 Add image.detect() for detecting multiple types.
…2697 Add image.detect() for detecting multiple types.
| Back | FazBrowse Home | New Git URL |
Closes #2697, #2769