def annotate(self, images): """Annotate images through GAX. :type images: list :param images: List containing pairs of :class:`~google.cloud.vision.image.Image` and :class:`~google.cloud.vision.feature.Feature`. e.g. [(image, [feature_one, feature_two]),] :rtype: list :returns: List of :class:`~google.cloud.vision.annotations.Annotations`. """ requests = [] for image, features in images: gapic_features = [ _to_gapic_feature(feature) for feature in features ] gapic_image = _to_gapic_image(image) request = image_annotator_pb2.AnnotateImageRequest( image=gapic_image, features=gapic_features) requests.append(request) annotator_client = self._annotator_client responses = annotator_client.batch_annotate_images(requests).responses return [Annotations.from_pb(response) for response in responses]
def annotate(self, image, features): """Annotate images through GAX. :type image: :class:`~google.cloud.vision.image.Image` :param image: Instance of ``Image``. :type features: list :param features: List of :class:`~google.cloud.vision.feature.Feature`. :rtype: list :returns: List of :class:`~google.cloud.vision.annotations.Annotations`. """ gapic_features = [_to_gapic_feature(feature) for feature in features] gapic_image = _to_gapic_image(image) request = image_annotator_pb2.AnnotateImageRequest( image=gapic_image, features=gapic_features) requests = [request] annotator_client = self._annotator_client responses = annotator_client.batch_annotate_images(requests).responses return [Annotations.from_pb(response) for response in responses]
def annotate(self, image, features): """Annotate images through GAX. :type image: :class:`~google.cloud.vision.image.Image` :param image: Instance of ``Image``. :type features: list :param features: List of :class:`~google.cloud.vision.feature.Feature`. :rtype: :class:`~google.cloud.vision.annotations.Annotations` :returns: Instance of ``Annotations`` with results or ``None``. """ gapic_features = [_to_gapic_feature(feature) for feature in features] gapic_image = _to_gapic_image(image) request = image_annotator_pb2.AnnotateImageRequest( image=gapic_image, features=gapic_features) requests = [request] annotator_client = self._annotator_client images = annotator_client.batch_annotate_images(requests) if len(images.responses) == 1: return Annotations.from_pb(images.responses[0]) elif len(images.responses) > 1: raise NotImplementedError( 'Multiple image processing is not yet supported.')