ImageAnnotatorClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Service that performs Google Cloud Vision API detection tasks over client images, such as face, landmark, logo, label, and text detection. The ImageAnnotator service returns detected entities from the images.
Inheritance
builtins.object > google.cloud.vision_helpers.VisionHelpers > builtins.object > google.cloud.vision_v1.gapic.image_annotator_client.ImageAnnotatorClient > ImageAnnotatorClientMethods
ImageAnnotatorClient
ImageAnnotatorClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
credentials |
google.auth.credentials.Credentials
The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to |
client_config |
dict
DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used. |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
client_options |
Union[dict, google.api_core.client_options.ClientOptions]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
annotate_image
annotate_image(request, retry=None, timeout=None)
Run image detection and annotation for an image.
.. rubric:: Example
from google.cloud.vision_v1 import ImageAnnotatorClient client = ImageAnnotatorClient() request = { ... 'image': { ... 'source': {'image_uri': 'https://foo.com/image.jpg'}, ... }, ... } response = client.annotate_image(request)
Name | Description |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
async_batch_annotate_files
async_batch_annotate_files(requests, parent=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Run asynchronous image detection and annotation for a list of generic
files, such as PDF files, which may contain multiple pages and multiple
images per page. Progress and results can be retrieved through the
google.longrunning.Operations
interface. Operation.metadata
contains OperationMetadata
(metadata). Operation.response
contains AsyncBatchAnnotateFilesResponse
(results).
.. rubric:: Example
from google.cloud import vision_v1
client = vision_v1.ImageAnnotatorClient()
TODO: Initialize
requests
:requests = []
response = client.async_batch_annotate_files(requests)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
requests |
list[Union[dict, AsyncAnnotateFileRequest]]
Required. Individual async file annotation requests for this batch. If a dict is provided, it must be of the same form as the protobuf message AsyncAnnotateFileRequest |
parent |
str
Optional. Target project and location to make a call. Format: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
async_batch_annotate_images
async_batch_annotate_images(requests, output_config, parent=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Run asynchronous image detection and annotation for a list of images.
Progress and results can be retrieved through the
google.longrunning.Operations
interface. Operation.metadata
contains OperationMetadata
(metadata). Operation.response
contains AsyncBatchAnnotateImagesResponse
(results).
This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
.. rubric:: Example
from google.cloud import vision_v1
client = vision_v1.ImageAnnotatorClient()
TODO: Initialize
requests
:requests = []
TODO: Initialize
output_config
:output_config = {}
response = client.async_batch_annotate_images(requests, output_config)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
requests |
list[Union[dict, AnnotateImageRequest]]
Required. Individual image annotation requests for this batch. If a dict is provided, it must be of the same form as the protobuf message AnnotateImageRequest |
output_config |
Union[dict, OutputConfig]
Required. The desired output location and metadata (e.g. format). If a dict is provided, it must be of the same form as the protobuf message OutputConfig |
parent |
str
Optional. Target project and location to make a call. Format: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
batch_annotate_files
batch_annotate_files(requests, parent=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported.
This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
.. rubric:: Example
from google.cloud import vision_v1
client = vision_v1.ImageAnnotatorClient()
TODO: Initialize
requests
:requests = []
response = client.batch_annotate_files(requests)
Name | Description |
requests |
list[Union[dict, AnnotateFileRequest]]
Required. The list of file annotation requests. Right now we support only one AnnotateFileRequest in BatchAnnotateFilesRequest. If a dict is provided, it must be of the same form as the protobuf message AnnotateFileRequest |
parent |
str
Optional. Target project and location to make a call. Format: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
batch_annotate_images
batch_annotate_images(requests, parent=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Run image detection and annotation for a batch of images.
.. rubric:: Example
from google.cloud import vision_v1
client = vision_v1.ImageAnnotatorClient()
TODO: Initialize
requests
:requests = []
response = client.batch_annotate_images(requests)
Name | Description |
requests |
list[Union[dict, AnnotateImageRequest]]
Required. Individual image annotation requests for this batch. If a dict is provided, it must be of the same form as the protobuf message AnnotateImageRequest |
parent |
str
Optional. Target project and location to make a call. Format: |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
crop_hints
crop_hints(image, max_results=None, retry=None, timeout=None, **kwargs)
Return crop hints information.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
document_text_detection
document_text_detection(
image, max_results=None, retry=None, timeout=None, **kwargs
)
Perform document text detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
face_detection
face_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform face detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
ImageAnnotatorClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
ImageAnnotatorClient | The constructed client. |
image_properties
image_properties(image, max_results=None, retry=None, timeout=None, **kwargs)
Return image properties information.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
label_detection
label_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform label detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
landmark_detection
landmark_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform landmark detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
logo_detection
logo_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform logo detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
object_localization
object_localization(image, max_results=None, retry=None, timeout=None, **kwargs)
Return object localization information.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
product_search
product_search(image, max_results=None, retry=None, timeout=None, **kwargs)
Return product search information.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
safe_search_detection
safe_search_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform safe search detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
text_detection
text_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform text detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |
web_detection
web_detection(image, max_results=None, retry=None, timeout=None, **kwargs)
Perform web detection.
Name | Description |
kwargs |
dict
Additional properties to be set on the AnnotateImageRequest. |
image |
Image
The image to analyze. |
max_results |
int
Number of results to return, does not apply for TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, or CROP_HINTS. |
retry |
int
Number of retries to do before giving up. |
timeout |
int
Number of seconds before timing out. |
Type | Description |
AnnotateImageResponse | The API response. |