/AWS1/IF_REK=>DETECTCUSTOMLABELS()¶
About DetectCustomLabels¶
This operation applies only to Amazon Rekognition Custom Labels.
Detects custom labels in a supplied image by using an Amazon Rekognition Custom Labels model.
You specify which version of a model version to use by using the ProjectVersionArn input
parameter.
You pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.
For each object that the model version detects on an image, the API returns a
(CustomLabel) object in an array (CustomLabels).
Each CustomLabel object provides the label name (Name), the level
of confidence that the image contains the object (Confidence), and
object location information, if it exists, for the label on the image (Geometry).
To filter labels that are returned, specify a value for MinConfidence.
DetectCustomLabelsLabels only returns labels with a confidence that's higher than
the specified value.
The value of MinConfidence maps to the assumed threshold values
created during training. For more information, see Assumed threshold
in the Amazon Rekognition Custom Labels Developer Guide.
Amazon Rekognition Custom Labels metrics expresses an assumed threshold as a floating point value between 0-1. The range of
MinConfidence normalizes the threshold value to a percentage value (0-100). Confidence
responses from DetectCustomLabels are also returned as a percentage.
You can use MinConfidence to change the precision and recall or your model.
For more information, see
Analyzing an image in the Amazon Rekognition Custom Labels Developer Guide.
If you don't specify a value for MinConfidence, DetectCustomLabels
returns labels based on the assumed threshold of each label.
This is a stateless API operation. That is, the operation does not persist any data.
This operation requires permissions to perform the
rekognition:DetectCustomLabels action.
For more information, see Analyzing an image in the Amazon Rekognition Custom Labels Developer Guide.
Method Signature¶
METHODS /AWS1/IF_REK~DETECTCUSTOMLABELS
IMPORTING
!IV_PROJECTVERSIONARN TYPE /AWS1/REKPROJECTVERSIONARN OPTIONAL
!IO_IMAGE TYPE REF TO /AWS1/CL_REKIMAGE OPTIONAL
!IV_MAXRESULTS TYPE /AWS1/REKUINTEGER OPTIONAL
!IV_MINCONFIDENCE TYPE /AWS1/RT_FLOAT_AS_STRING OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_rekdetectcustlabels01
RAISING
/AWS1/CX_REKACCESSDENIEDEX
/AWS1/CX_REKIMAGETOOLARGEEX
/AWS1/CX_REKINTERNALSERVERERR
/AWS1/CX_REKINVIMAGEFORMATEX
/AWS1/CX_REKINVALIDPARAMETEREX
/AWS1/CX_REKINVALIDS3OBJECTEX
/AWS1/CX_REKLIMITEXCEEDEDEX
/AWS1/CX_REKPROVTHRUPUTEXCDEX
/AWS1/CX_REKRESOURCENOTFOUNDEX
/AWS1/CX_REKRESOURCENOTREADYEX
/AWS1/CX_REKTHROTTLINGEX
/AWS1/CX_REKCLIENTEXC
/AWS1/CX_REKSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_projectversionarn TYPE /AWS1/REKPROJECTVERSIONARN /AWS1/REKPROJECTVERSIONARN¶
The ARN of the model version that you want to use. Only models associated with Custom Labels projects accepted by the operation. If a provided ARN refers to a model version associated with a project for a different feature type, then an InvalidParameterException is returned.
io_image TYPE REF TO /AWS1/CL_REKIMAGE /AWS1/CL_REKIMAGE¶
Provides the input image either as bytes or an S3 object.
You pass image bytes to an Amazon Rekognition API operation by using the
Bytesproperty. For example, you would use theBytesproperty to pass an image loaded from a local file system. Image bytes passed by using theBytesproperty must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations.For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.
You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the
S3Objectproperty. Images stored in an S3 bucket do not need to be base64-encoded.The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.
If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.
For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide.
Optional arguments:¶
iv_maxresults TYPE /AWS1/REKUINTEGER /AWS1/REKUINTEGER¶
Maximum number of results you want the service to return in the response. The service returns the specified number of highest confidence labels ranked from highest confidence to lowest.
iv_minconfidence TYPE /AWS1/RT_FLOAT_AS_STRING /AWS1/RT_FLOAT_AS_STRING¶
Specifies the minimum confidence level for the labels to return.
DetectCustomLabelsdoesn't return any labels with a confidence value that's lower than this specified value. If you specify a value of 0,DetectCustomLabelsreturns all labels, regardless of the assumed threshold applied to each label. If you don't specify a value forMinConfidence,DetectCustomLabelsreturns labels based on the assumed threshold of each label.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_rekdetectcustlabels01 /AWS1/CL_REKDETECTCUSTLABELS01¶
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->detectcustomlabels(
io_image = new /aws1/cl_rekimage(
io_s3object = new /aws1/cl_reks3object(
iv_bucket = |string|
iv_name = |string|
iv_version = |string|
)
iv_bytes = '5347567362473873563239796247513D'
)
iv_maxresults = 123
iv_minconfidence = |0.1|
iv_projectversionarn = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
LOOP AT lo_result->get_customlabels( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_string = lo_row_1->get_name( ).
lv_percent = lo_row_1->get_confidence( ).
lo_geometry = lo_row_1->get_geometry( ).
IF lo_geometry IS NOT INITIAL.
lo_boundingbox = lo_geometry->get_boundingbox( ).
IF lo_boundingbox IS NOT INITIAL.
lv_float = lo_boundingbox->get_width( ).
lv_float = lo_boundingbox->get_height( ).
lv_float = lo_boundingbox->get_left( ).
lv_float = lo_boundingbox->get_top( ).
ENDIF.
LOOP AT lo_geometry->get_polygon( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_float = lo_row_3->get_x( ).
lv_float = lo_row_3->get_y( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
To detect custom labels in an image with an Amazon Rekognition Custom Labels model¶
Detects custom labels in an image with an Amazon Rekognition Custom Labels model
DATA(lo_result) = lo_client->detectcustomlabels(
io_image = new /aws1/cl_rekimage(
io_s3object = new /aws1/cl_reks3object(
iv_bucket = |custom-labels-console-us-east-1-1111111111|
iv_name = |assets/flowers_1_test_dataset/camellia4.jpg|
)
)
iv_maxresults = 100
iv_minconfidence = |50|
iv_projectversionarn = |arn:aws:rekognition:us-east-1:111122223333:project/my-project/version/my-project.2023-07-31T11.49.37/1690829378219|
).