Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.
Descripción de un modelo (SDK)
Puede utilizar la API de DescribeProjectVersions
para obtener información sobre la versión de un modelo. Si no indica VersionName
, DescribeProjectVersions
devolverá las descripciones de todas las versiones del modelo en el proyecto.
Cómo describir un modelo (SDK)
-
Si aún no lo ha hecho, instale y configure la AWS CLI y los SDK de AWS. Para obtener más información, consulte Paso 4: Configure los SDK y AWS CLIAWS.
-
Incluya la descripción de la versión de un modelo con el siguiente código.
- AWS CLI
-
Cambie el valor de
project-arn
por el ARN del proyecto que desee describir. Cambie el valor deversion-name
por la versión del modelo que desee describir.aws rekognition describe-project-versions --project-arn
project_arn
\ --version-namesversion_name
\ --profile custom-labels-access - Python
-
Utilice el siguiente código. Indique los siguientes parámetros de línea de comandos:
-
project_arn: el ARN del modelo que desea describir.
-
model_version: la versión del modelo que desea describir.
Por ejemplo:
python describe_model.py
project_arn
model_version
# 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 model. """ import argparse import logging import boto3 from botocore.exceptions import ClientError logger = logging.getLogger(__name__) def describe_model(rek_client, project_arn, version_name): """ Describes an Amazon Rekognition Custom Labels model. :param rek_client: The Amazon Rekognition Custom Labels Boto3 client. :param project_arn: The ARN of the prject that contains the model. :param version_name: The version name of the model that you want to describe. """ try: # Describe the model logger.info("Describing model: %s for project %s", version_name, project_arn) describe_response = rek_client.describe_project_versions(ProjectArn=project_arn, VersionNames=[version_name]) for model in describe_response['ProjectVersionDescriptions']: print(f"Created: {str(model['CreationTimestamp'])} ") print(f"ARN: {str(model['ProjectVersionArn'])} ") if 'BillableTrainingTimeInSeconds' in model: print( f"Billing training time (minutes): {str(model['BillableTrainingTimeInSeconds']/60)} ") print("Evaluation results: ") if 'EvaluationResult' in model: evaluation_results = model['EvaluationResult'] print(f"\tF1 score: {str(evaluation_results['F1Score'])}") print( f"\tSummary location: s3://{evaluation_results['Summary']['S3Object']['Bucket']}/{evaluation_results['Summary']['S3Object']['Name']}") if 'ManifestSummary' in model: print( f"Manifest summary location: s3://{model['ManifestSummary']['S3Object']['Bucket']}/{model['ManifestSummary']['S3Object']['Name']}") if 'OutputConfig' in model: print( f"Training output location: s3://{model['OutputConfig']['S3Bucket']}/{model['OutputConfig']['S3KeyPrefix']}") if 'MinInferenceUnits' in model: print( f"Minimum inference units: {str(model['MinInferenceUnits'])}") if 'MaxInferenceUnits' in model: print( f"Maximum Inference units: {str(model['MaxInferenceUnits'])}") print("Status: " + model['Status']) print("Message: " + model['StatusMessage']) except ClientError as err: logger.exception( "Couldn't describe model: %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( "project_arn", help="The ARN of the project in which the model resides." ) parser.add_argument( "version_name", help="The version of the model 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 model: {args.version_name} for project {args.project_arn}.") # Describe the model. session = boto3.Session(profile_name='custom-labels-access') rekognition_client = session.client("rekognition") describe_model(rekognition_client, args.project_arn, args.version_name) print( f"Finished describing model: {args.version_name} for project {args.project_arn}.") except ClientError as err: error_message = f"Problem describing model: {err}" logger.exception(error_message) print(error_message) except Exception as err: error_message = f"Problem describing model: {err}" logger.exception(error_message) print(error_message) if __name__ == "__main__": main()
-
- Java V2
-
Utilice el siguiente código. Indique los siguientes parámetros de línea de comandos:
-
project_arn: el ARN del modelo que desea describir.
-
model_version: la versión del modelo que desea describir.
/* 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.DescribeProjectVersionsRequest; import software.amazon.awssdk.services.rekognition.model.DescribeProjectVersionsResponse; import software.amazon.awssdk.services.rekognition.model.EvaluationResult; import software.amazon.awssdk.services.rekognition.model.GroundTruthManifest; import software.amazon.awssdk.services.rekognition.model.OutputConfig; import software.amazon.awssdk.services.rekognition.model.ProjectVersionDescription; import software.amazon.awssdk.services.rekognition.model.RekognitionException; import java.util.logging.Level; import java.util.logging.Logger; public class DescribeModel { public static final Logger logger = Logger.getLogger(DescribeModel.class.getName()); public static void describeMyModel(RekognitionClient rekClient, String projectArn, String versionName) { try { // If a single version name is supplied, build request argument DescribeProjectVersionsRequest describeProjectVersionsRequest = null; if (versionName == null) { describeProjectVersionsRequest = DescribeProjectVersionsRequest.builder().projectArn(projectArn) .build(); } else { describeProjectVersionsRequest = DescribeProjectVersionsRequest.builder().projectArn(projectArn) .versionNames(versionName).build(); } DescribeProjectVersionsResponse describeProjectVersionsResponse = rekClient .describeProjectVersions(describeProjectVersionsRequest); for (ProjectVersionDescription projectVersionDescription : describeProjectVersionsResponse .projectVersionDescriptions()) { System.out.println("ARN: " + projectVersionDescription.projectVersionArn()); System.out.println("Status: " + projectVersionDescription.statusAsString()); System.out.println("Message: " + projectVersionDescription.statusMessage()); if (projectVersionDescription.billableTrainingTimeInSeconds() != null) { System.out.println( "Billable minutes: " + (projectVersionDescription.billableTrainingTimeInSeconds() / 60)); } if (projectVersionDescription.evaluationResult() != null) { EvaluationResult evaluationResult = projectVersionDescription.evaluationResult(); System.out.println("F1 Score: " + evaluationResult.f1Score()); System.out.println("Summary location: s3://" + evaluationResult.summary().s3Object().bucket() + "/" + evaluationResult.summary().s3Object().name()); } if (projectVersionDescription.manifestSummary() != null) { GroundTruthManifest manifestSummary = projectVersionDescription.manifestSummary(); System.out.println("Manifest summary location: s3://" + manifestSummary.s3Object().bucket() + "/" + manifestSummary.s3Object().name()); } if (projectVersionDescription.outputConfig() != null) { OutputConfig outputConfig = projectVersionDescription.outputConfig(); System.out.println( "Training output: s3://" + outputConfig.s3Bucket() + "/" + outputConfig.s3KeyPrefix()); } if (projectVersionDescription.minInferenceUnits() != null) { System.out.println("Min inference units: " + projectVersionDescription.minInferenceUnits()); } System.out.println(); } } catch (RekognitionException rekError) { logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage()); throw rekError; } } public static void main(String args[]) { String projectArn = null; String versionName = null; final String USAGE = "\n" + "Usage: " + "<project_arn> <version_name>\n\n" + "Where:\n" + " project_arn - The ARN of the project that contains the models you want to describe.\n\n" + " version_name - (optional) The version name of the model that you want to describe. \n\n" + " If you don't specify a value, all model versions are described.\n\n"; if (args.length > 2 || args.length == 0) { System.out.println(USAGE); System.exit(1); } projectArn = args[0]; if (args.length == 2) { versionName = args[1]; } try { // Get the Rekognition client. RekognitionClient rekClient = RekognitionClient.builder() .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access")) .region(Region.US_WEST_2) .build(); // Describe the model describeMyModel(rekClient, projectArn, versionName); rekClient.close(); } catch (RekognitionException rekError) { logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage()); System.exit(1); } } }
-