ImageAnnotatorClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.vision_v1.services.image_annotator.transports.base.ImageAnnotatorTransport]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)クライアント画像に対して Google Cloud Vision API の顔検出、ランドマーク検出、ロゴ検出、ラベル検出、テキスト検出などの検出タスクを実行するサービス。ImageAnnotator サービスは、画像から検出されたエンティティを返します。
プロパティ
transport
クライアント インスタンスで使用されるトランスポートを返します。
| 戻り値 | |
|---|---|
| 型 | 説明 |
ImageAnnotatorTransport | クライアント インスタンスで使用されるトランスポート。 |
メソッド
ImageAnnotatorClient
ImageAnnotatorClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.vision_v1.services.image_annotator.transports.base.ImageAnnotatorTransport]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)画像アノテーター クライアントをインスタンス化します。
| パラメータ | |
|---|---|
| 名前 | 説明 |
credentials |
Optional[google.auth.credentials.Credentials]
リクエストに付加する認証情報。これらの認証情報は、サービスに対するアプリケーションを識別します。指定されていない場合、クライアントは環境から認証情報を取得しようとします。 |
transport |
Union[str, ImageAnnotatorTransport]
使用するトランスポート。None に設定すると、トランスポートが自動的に選択されます。 |
client_options |
Optional[Union[google.api_core.client_options.ClientOptions, dict]]
クライアントのカスタム オプション。 |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
API リクエストとともにユーザー エージェント文字列を送信するために使用されるクライアント情報。 |
| 例外 | |
|---|---|
| 型 | 説明 |
google.auth.exceptions.MutualTLSChannelError | なんらかの理由で相互 TLS トランスポートの作成に失敗した場合。 |
__exit__
__exit__(type, value, traceback)基盤となるトランスポートのリソースを解放します。
async_batch_annotate_files
async_batch_annotate_files(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1.types.image_annotator.AsyncBatchAnnotateFilesRequest,
dict,
]
] = None,
*,
requests: typing.Optional[
typing.MutableSequence[
google.cloud.vision_v1.types.image_annotator.AsyncAnnotateFileRequest
]
] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.OperationPDF ファイルなど、汎用ファイルのリストに対して非同期で画像検出とアノテーションを実行します。このファイルには複数のページが含まれている場合があります。また、各ページに複数の画像が存在することもあります。進行状況と結果は、google.longrunning.Operations インターフェースを介して取得できます。Operation.metadata には、OperationMetadata(メタデータ)が含まれます。Operation.response には、AsyncBatchAnnotateFilesResponse(結果)が含まれます。
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1
def sample_async_batch_annotate_files():
# Create a client
client = vision_v1.ImageAnnotatorClient()
# Initialize request argument(s)
request = vision_v1.AsyncBatchAnnotateFilesRequest(
)
# Make the request
operation = client.async_batch_annotate_files(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
| パラメータ | |
|---|---|
| 名前 | 説明 |
request |
Union[google.cloud.vision_v1.types.AsyncBatchAnnotateFilesRequest, dict]
リクエスト オブジェクト。複数の非同期ファイルのアノテーション リクエストが 1 回のサービス呼び出しでバッチ処理されます。 |
requests |
MutableSequence[google.cloud.vision_v1.types.AsyncAnnotateFileRequest]
必須。このバッチの個々の非同期ファイルのアノテーション リクエスト。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
google.api_core.operation.Operation | 長時間実行オペレーションを表すオブジェクト。オペレーションの結果の型は、非同期のバッチ ファイル アノテーション リクエストに対するレスポンスである AsyncBatchAnnotateFilesResponse になります。 |
batch_annotate_files
batch_annotate_files(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1.types.image_annotator.BatchAnnotateFilesRequest, dict
]
] = None,
*,
requests: typing.Optional[
typing.MutableSequence[
google.cloud.vision_v1.types.image_annotator.AnnotateFileRequest
]
] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.vision_v1.types.image_annotator.BatchAnnotateFilesResponse複数のファイルに対して一括で画像検出とアノテーションを実行するサービス。現在、application/pdf、image/tiff、image/gif のみがサポートされています。このサービスは、指定されたファイルから最大で 5 個のフレーム(gif)またはページ(PDF または tiff)を抽出して、抽出した各画像の検出とアノテーションを実行します(抽出対象は AnnotateFileRequest.pages で指定できます)。
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1
def sample_batch_annotate_files():
# Create a client
client = vision_v1.ImageAnnotatorClient()
# Initialize request argument(s)
request = vision_v1.BatchAnnotateFilesRequest(
)
# Make the request
response = client.batch_annotate_files(request=request)
# Handle the response
print(response)
| パラメータ | |
|---|---|
| 名前 | 説明 |
request |
Union[google.cloud.vision_v1.types.BatchAnnotateFilesRequest, dict]
リクエスト オブジェクト。BatchAnnotateFiles API を使用してファイルにアノテーションを設定するリクエストのリスト。 |
requests |
MutableSequence[google.cloud.vision_v1.types.AnnotateFileRequest]
必須。ファイル アノテーション リクエストのリスト。現在、BatchAnnotateFilesRequest では AnnotateFileRequest が 1 つだけサポートされています。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
google.cloud.vision_v1.types.BatchAnnotateFilesResponse | ファイル アノテーション レスポンスのリスト。 |
batch_annotate_images
batch_annotate_images(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1.types.image_annotator.BatchAnnotateImagesRequest,
dict,
]
] = None,
*,
requests: typing.Optional[
typing.MutableSequence[
google.cloud.vision_v1.types.image_annotator.AnnotateImageRequest
]
] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.vision_v1.types.image_annotator.BatchAnnotateImagesResponse画像のバッチに対して画像の検出とアノテーションを実行します。
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1
def sample_batch_annotate_images():
# Create a client
client = vision_v1.ImageAnnotatorClient()
# Initialize request argument(s)
request = vision_v1.BatchAnnotateImagesRequest(
)
# Make the request
response = client.batch_annotate_images(request=request)
# Handle the response
print(response)
| パラメータ | |
|---|---|
| 名前 | 説明 |
request |
Union[google.cloud.vision_v1.types.BatchAnnotateImagesRequest, dict]
リクエスト オブジェクト。複数の画像アノテーション リクエストが 1 回のサービス呼び出しでバッチ処理されます。 |
requests |
MutableSequence[google.cloud.vision_v1.types.AnnotateImageRequest]
必須。このバッチの個々の画像アノテーション リクエスト。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
google.cloud.vision_v1.types.BatchAnnotateImagesResponse | バッチ画像アノテーション リクエストに対するレスポンス。 |
common_billing_account_path
common_billing_account_path(billing_account: str) -> str完全修飾された billing_account 文字列を返します。
common_folder_path
common_folder_path(folder: str) -> str完全修飾フォルダ文字列を返します。
common_location_path
common_location_path(project: str, location: str) -> str完全修飾ロケーション文字列を返します。
common_organization_path
common_organization_path(organization: str) -> str完全修飾された組織文字列を返します。
common_project_path
common_project_path(project: str) -> str完全修飾プロジェクト文字列を返します。
from_service_account_file
from_service_account_file(filename: str, *args, **kwargs)指定された認証情報ファイルを使用して、このクライアントのインスタンスを作成します。
| パラメータ | |
|---|---|
| 名前 | 説明 |
filename |
str
サービス アカウントの秘密鍵の JSON ファイルへのパス。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
ImageAnnotatorClient | 構築されたクライアント。 |
from_service_account_info
from_service_account_info(info: dict, *args, **kwargs)指定された認証情報を使用して、このクライアントのインスタンスを作成します。
| パラメータ | |
|---|---|
| 名前 | 説明 |
info |
dict
サービス アカウントの秘密鍵情報。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
ImageAnnotatorClient | 構築されたクライアント。 |
from_service_account_json
from_service_account_json(filename: str, *args, **kwargs)指定された認証情報ファイルを使用して、このクライアントのインスタンスを作成します。
| パラメータ | |
|---|---|
| 名前 | 説明 |
filename |
str
サービス アカウントの秘密鍵の JSON ファイルへのパス。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
ImageAnnotatorClient | 構築されたクライアント。 |
get_mtls_endpoint_and_cert_source
get_mtls_endpoint_and_cert_source(
client_options: typing.Optional[
google.api_core.client_options.ClientOptions
] = None,
)相互 TLS の API エンドポイントとクライアント証明書のソースを返します。
クライアント証明書のソースは次の順序で決定されます。(1)GOOGLE_API_USE_CLIENT_CERTIFICATE 環境変数が「true」でない場合、クライアント証明書のソースは None になります。(2)client_options.client_cert_source が指定されている場合は、指定されたものを使用します。デフォルトのクライアント証明書ソースが存在する場合は、デフォルトのものを使用します。それ以外の場合は、クライアント証明書ソースは None になります。
API エンドポイントは次の順序で決定されます。(1)client_options.api_endpoint が指定されている場合は、指定されたものを使用します。(2)GOOGLE_API_USE_CLIENT_CERTIFICATE 環境変数が「always」の場合はデフォルトの mTLS エンドポイントを使用し、環境変数が「never」の場合はデフォルトの API エンドポイントを使用します。それ以外の場合は、クライアント証明書のソースが存在する場合はデフォルトの mTLS エンドポイントを使用し、存在しない場合はデフォルトの API エンドポイントを使用します。
詳しくは、https://google.aip.dev/auth/4114 をご覧ください。
| パラメータ | |
|---|---|
| 名前 | 説明 |
client_options |
google.api_core.client_options.ClientOptions
クライアントのカスタム オプション。このメソッドでは、 |
| 例外 | |
|---|---|
| 型 | 説明 |
google.auth.exceptions.MutualTLSChannelError | エラーが発生した場合。 |
| 戻り値 | |
|---|---|
| 型 | 説明 |
Tuple[str, Callable[[], Tuple[bytes, bytes]]] | 使用する API エンドポイントとクライアント証明書のソースを返します。 |
parse_common_billing_account_path
parse_common_billing_account_path(path: str) -> typing.Dict[str, str]billing_account パスを構成セグメントに解析します。
parse_common_folder_path
parse_common_folder_path(path: str) -> typing.Dict[str, str]フォルダパスを構成セグメントに解析します。
parse_common_location_path
parse_common_location_path(path: str) -> typing.Dict[str, str]ロケーション パスを構成セグメントに解析します。
parse_common_organization_path
parse_common_organization_path(path: str) -> typing.Dict[str, str]組織パスを構成セグメントに解析します。
parse_common_project_path
parse_common_project_path(path: str) -> typing.Dict[str, str]プロジェクト パスをコンポーネント セグメントに解析します。
parse_product_path
parse_product_path(path: str) -> typing.Dict[str, str]商品パスを構成セグメントに解析します。
parse_product_set_path
parse_product_set_path(path: str) -> typing.Dict[str, str]product_set パスを解析して、その構成セグメントに分割します。
product_path
product_path(project: str, location: str, product: str) -> str完全修飾されたプロダクト文字列を返します。
product_set_path
product_set_path(project: str, location: str, product_set: str) -> str完全修飾 product_set 文字列を返します。