Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Décrire un ensemble de données (SDK)
Vous pouvez utiliser l'DescribeDataset
API pour obtenir des informations sur un ensemble de données.
Pour décrire un jeu de données (SDK)
-
Si vous ne l'avez pas déjà fait, installez et configurez lesAWS CLI et lesAWS SDK. Pour plus d'informations, veuillez consulter Étape 4 : Configurez le AWS CLI and AWS SDKs.
-
Utilisez l'exemple de code suivant pour décrire un ensemble de données.
- AWS CLI
-
Remplacez la valeur par
dataset-arn
l'ARN du jeu de données que vous souhaitez décrire.aws rekognition describe-dataset --dataset-arn
dataset_arn
\ --profile custom-labels-access - Python
-
Utilisez le code suivant. Fournissez les paramètres de ligne de commande suivants :
-
dataset_arn — ARN du jeu de données que vous souhaitez décrire.
# 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 du jeu de données que vous souhaitez décrire.
/* 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); } } }
-