Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
Beschreibung eines Datensatzes (SDK)
Sie können dieDescribeDataset
-API verwenden, um Informationen über ein Dataset abzurufen.
Um einen Datensatz zu beschreiben (SDK)
-
Falls noch erfolgt, noch erfolgtAWS CLI undAWS konfigurieren. Weitere Informationen finden Sie unter Schritt 4: Richten Sie die AWS CLI und SDKs ein AWS.
-
Verwenden Sie den folgenden Beispielcode, um einen Datensatz zu beschreiben.
- AWS CLI
-
Ändern Sie den Wert von
dataset-arn
in den ARN des Datensatzes, den Sie beschreiben möchten.aws rekognition describe-dataset --dataset-arn
dataset_arn
\ --profile custom-labels-access - Python
-
Verwenden Sie folgenden Code. Geben Sie die folgenden Befehlszeilenparameter an:
-
dataset_arn — der ARN des Datensatzes, den Sie beschreiben möchten.
# 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 — der ARN des Datensatzes, den Sie beschreiben möchten.
/* 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); } } }
-