翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
データセットの記述 (SDK)
DescribeDataset
API を使用して、データセットに関する情報を取得できます。
データセットを記述するには (SDK)
-
現時点で AWS CLI と AWS SDK のインストールと設定が完了していない場合は、インストールと設定を実行します。詳細については、「ステップ 4: AWS CLI と AWS SDKsを設定する」を参照してください。
-
次のサンプルコードを使用して、データセットを記述します。
- AWS CLI
-
dataset-arn
の値を記述するデータセットの ARN に変更します。aws rekognition describe-dataset --dataset-arn
dataset_arn
\ --profile custom-labels-access - Python
-
次のコードを使用します。次のコマンドラインパラメータを指定します。
-
dataset_arn - 記述するデータセットの ARN。
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """ Purpose Shows how to describe an Amazon Rekognition Custom Labels dataset. """ import argparse import logging import boto3 from botocore.exceptions import ClientError logger = logging.getLogger(__name__) def describe_dataset(rek_client, dataset_arn): """ Describes an Amazon Rekognition Custom Labels dataset. :param rek_client: The Amazon Rekognition Custom Labels Boto3 client. :param dataset_arn: The ARN of the dataset that you want to describe. """ try: # Describe the dataset logger.info("Describing dataset %s", dataset_arn) dataset = rek_client.describe_dataset(DatasetArn=dataset_arn) description = dataset['DatasetDescription'] print(f"Created: {str(description['CreationTimestamp'])}") print(f"Updated: {str(description['LastUpdatedTimestamp'])}") print(f"Status: {description['Status']}") print(f"Status message: {description['StatusMessage']}") print(f"Status code: {description['StatusMessageCode']}") print("Stats:") print( f"\tLabeled entries: {description['DatasetStats']['LabeledEntries']}") print( f"\tTotal entries: {description['DatasetStats']['TotalEntries']}") print(f"\tTotal labels: {description['DatasetStats']['TotalLabels']}") except ClientError as err: logger.exception("Couldn't describe dataset: %s", err.response['Error']['Message']) raise def add_arguments(parser): """ Adds command line arguments to the parser. :param parser: The command line parser. """ parser.add_argument( "dataset_arn", help="The ARN of the dataset that you want to describe." ) def main(): logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") try: # Get command line arguments. parser = argparse.ArgumentParser(usage=argparse.SUPPRESS) add_arguments(parser) args = parser.parse_args() print(f"Describing dataset {args.dataset_arn}") # Describe the dataset. session = boto3.Session(profile_name='custom-labels-access') rekognition_client = session.client("rekognition") describe_dataset(rekognition_client, args.dataset_arn) print(f"Finished describing dataset: {args.dataset_arn}") except ClientError as err: error_message=f"Problem describing dataset: {err}" logger.exception(error_message) print(error_message) except Exception as err: error_message = f"Problem describing dataset: {err}" logger.exception(error_message) print(error_message) if __name__ == "__main__": main()
-
- Java V2
-
-
dataset_arn - 記述するデータセットの ARN。
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package com.example.rekognition; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.rekognition.RekognitionClient; import software.amazon.awssdk.services.rekognition.model.DatasetDescription; import software.amazon.awssdk.services.rekognition.model.DatasetStats; import software.amazon.awssdk.services.rekognition.model.DescribeDatasetRequest; import software.amazon.awssdk.services.rekognition.model.DescribeDatasetResponse; import software.amazon.awssdk.services.rekognition.model.RekognitionException; import java.util.logging.Level; import java.util.logging.Logger; public class DescribeDataset { public static final Logger logger = Logger.getLogger(DescribeDataset.class.getName()); public static void describeMyDataset(RekognitionClient rekClient, String datasetArn) { try { DescribeDatasetRequest describeDatasetRequest = DescribeDatasetRequest.builder().datasetArn(datasetArn) .build(); DescribeDatasetResponse describeDatasetResponse = rekClient.describeDataset(describeDatasetRequest); DatasetDescription datasetDescription = describeDatasetResponse.datasetDescription(); DatasetStats datasetStats = datasetDescription.datasetStats(); System.out.println("ARN: " + datasetArn); System.out.println("Created: " + datasetDescription.creationTimestamp().toString()); System.out.println("Updated: " + datasetDescription.lastUpdatedTimestamp().toString()); System.out.println("Status: " + datasetDescription.statusAsString()); System.out.println("Message: " + datasetDescription.statusMessage()); System.out.println("Total Labels: " + datasetStats.totalLabels().toString()); System.out.println("Total entries: " + datasetStats.totalEntries().toString()); System.out.println("Entries with labels: " + datasetStats.labeledEntries().toString()); System.out.println("Entries with at least 1 error: " + datasetStats.errorEntries().toString()); } catch (RekognitionException rekError) { logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage()); throw rekError; } } public static void main(String[] args) { final String USAGE = "\n" + "Usage: " + "<dataset_arn>\n\n" + "Where:\n" + " dataset_arn - The ARN of the dataset that you want to describe.\n\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1); } String datasetArn = args[0]; try { // Get the Rekognition client. RekognitionClient rekClient = RekognitionClient.builder() .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access")) .region(Region.US_WEST_2) .build(); // Describe the dataset. describeMyDataset(rekClient, datasetArn); rekClient.close(); } catch (RekognitionException rekError) { logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage()); System.exit(1); } } }
-
既存のデータセットを使用したデータセットの作成 (SDK)
データセットエントリの一覧表示 (SDK)