AWS Rekognition DetectLabels
AWS Rekognition DetectLabels transformation allows users to automatically detect objects, scenes, and concepts within images.
Using machine learning algorithms, the DetectLabels API analyzes visual content and returns a list of labels with associated confidence scores. These labels can include things like a person, car, dog, mountain, beach, and many others.
This service is useful for a wide range of applications, such as image search, content moderation, and automatic metadata generation.
Installing the AWS Rekognition add-on is a must for using this transformation.
Params
Maximum Labels (l
)
This parameter in AWS Rekognition DetectLabels
is used to specify the maximum number of labels (objects) that should be returned in the API response.
Available values are from 0
to 10
. The default value is 5
.
If the number of labels detected in an image is greater than the specified l
value, AWS Rekognition DetectLabels
will only return the top MaxLabels labels with the highest confidence scores.
For example, if l
is set to 1
and Rekognition detects 2
labels in an image, it will return only the top 1
label with the highest confidence scores.
Adjusting the l
parameter can be useful in cases where you only need to retrieve the most relevant labels for your application or when you want to reduce the size of the API response.
Minimum Confidence (c
)
This parameter in AWS Rekognition DetectLabels
is used to specify the minimum confidence level required for a label to be included in the API response.
Available values are from 0
to 99
. The default value is 55
.
If the confidence score for a label is less than the specified c
value, the label will not be included in the API response. This can be useful for filtering out labels with low confidence scores that may not be relevant to your application.
For example, if c
is set to 70
and Rekognition detects 20
labels in an image, it will return only the labels with confidence scores of 70
or higher.
Adjusting the c
parameter can be useful in cases where you only want to retrieve labels that have a high level of confidence or when you want to filter out labels that are not relevant to your use case.
Instead of getting the output in a traditional CDN URL, you will get a JSON output from the Context API while the CDN URL will return the original image without any modifications.
- Input Image
- Context API Response
- URL
- React
- JavaScript
- Node.js
- Python
- Golang
- Kotlin
- C#
- PHP
<PixelBinImage
url="https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg"
/>
import Pixelbin from "@pixelbin/core";
const obj = {
cloudName: "dummy-cloudname",
zone: "FIDrmb",
version: "v2",
transformations: [],
filePath: "images/transformation/basic_girl_2.jpeg",
baseUrl: "https://cdn.pixelbin.io",
};
const url = Pixelbin.default.utils.objToUrl(obj);
// url
// https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
const Pixelbin = require("@pixelbin/admin");
const obj = {
cloudName: "dummy-cloudname",
zone: "FIDrmb",
version: "v2",
transformations: [],
filePath: "images/transformation/basic_girl_2.jpeg",
baseUrl: "https://cdn.pixelbin.io",
};
const url = Pixelbin.url.objToUrl(obj);
// url
// https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
from pixelbin.utils.url import obj_to_url
obj = {
"cloudName": "dummy-cloudname",
"zone": "FIDrmb",
"version": "v2",
"transformations": [],
"filePath": "images/transformation/basic_girl_2.jpeg",
"baseUrl": "https://cdn.pixelbin.io",
}
url = obj_to_url(obj)
# url
# https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
package main
import (
"fmt"
"github.com/pixelbin-dev/pixelbin-go/v2/sdk/utils/url"
)
func main() {
obj := map[string]interface{}{
"cloudName": "dummy-cloudname",
"zoneSlug": "FIDrmb",
"version": "v2",
"transformations": []map[string]interface{}{
},
"filePath": "images/transformation/basic_girl_2.jpeg",
"baseUrl": "https://cdn.pixelbin.io",
"options": map[string]interface{}{},
}
urlstring, err := url.ObjToUrl(obj)
if err != nil {
fmt.Println(err)
}
}
// url
// https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
import com.pixelbin.url.UrlObj
import com.pixelbin.Utils
import com.pixelbin.transformation.TransformationObj
fun main(){
val obj = UrlObj(
cloudName = "dummy-cloudname",
zone = "FIDrmb",
version = "v2",
transformation = arrayListOf(
),
filePath = "images/transformation/basic_girl_2.jpeg",
baseUrl = "https://cdn.pixelbin.io"
)
val url = Utils.objToUrl(obj)
}
// url
// https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
using System;
using System.Collections.Generic;
using System.IO;
using Pixelbin.Utils;
namespace ExampleNamespace
{
class ExampleClass
{
static void Main(string[] args)
{
UrlObj obj = new UrlObj(
version: "v2",
cloudName: "dummy-cloudname",
filePath: "images/transformation/basic_girl_2.jpeg",
zone: "FIDrmb",
baseUrl: "https://cdn.pixelbin.io",
transformations: new List<UrlTransformation>() {
}
);
string url = Url.ObjToUrl(obj);
}
}
}
// url
// https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
<?php
require 'vendor/autoload.php';
use Pixelbin\Utils\Url;
$obj = [
"cloudName" => "dummy-cloudname",
"zone" => "FIDrmb",
"version" => "v2",
"options" => [],
"transformations" => [
],
"filePath" => "images/transformation/basic_girl_2.jpeg",
"baseUrl" => "https://cdn.pixelbin.io",
];
$url = Url::obj_to_url($obj);
// url
// https://cdn.pixelbin.io/v2/dummy-cloudname/FIDrmb/original/images/transformation/basic_girl_2.jpeg
?>
The response for an API call with the above request body can look like this.
{
"Head": {
"Name": "Head",
"Confidence": 99.08606719970703,
"Instances": [],
"Parents": [
{
"Name": "Person"
}
]
},
"Person": {
"Name": "Person",
"Confidence": 99.08606719970703,
"Instances": [
{
"BoundingBox": {
"Height": 985.3714245557785,
"Width": 896.0858523845673,
"Top": 4.552185125648975,
"Left": 0.0029869079753552796
},
"Confidence": 98.22250366210938
}
],
"Parents": []
},
"Face": {
"Name": "Face",
"Confidence": 98.88607788085938,
"Instances": [],
"Parents": [
{
"Name": "Head"
},
{
"Name": "Person"
}
]
},
"Teen": {
"Name": "Teen",
"Confidence": 98.22250366210938,
"Instances": [
{
"BoundingBox": {
"Height": 985.3714245557785,
"Width": 896.0858523845673,
"Top": 4.552185125648975,
"Left": 0.0029869079753552796
},
"Confidence": 98.22250366210938
}
],
"Parents": [
{
"Name": "Person"
}
]
},
"Girl": {
"Name": "Girl",
"Confidence": 98.22250366210938,
"Instances": [
{
"BoundingBox": {
"Height": 985.3714245557785,
"Width": 896.0858523845673,
"Top": 4.552185125648975,
"Left": 0.0029869079753552796
},
"Confidence": 98.22250366210938
}
],
"Parents": [
{
"Name": "Female"
},
{
"Name": "Person"
}
]
}
}
The Context API Response tab includes an array of labels (Head, Person, Face, Teen, and Girl are the labels), where each label is represented by a JSON object that contains the following information:
Property | Description |
---|---|
Name | A string value that represents the name of the label detected in the media content. |
Confidence | A float value between 0 and 100 represents the level of confidence that the label is present in the media content. |
Instances | An array of instances where each instance is represented by a JSON object that contains a BoudingBox or Confidence. Learn More |
Instances[].Confidence | A float value between 0 and 100 represents the level of confidence that the detected label is present in the instance. |
Instances[].BoudingBox | Identifies the bounding box around the label, face, text, object of interest, or personal protective equipment. The left (x-coordinate) and top (y-coordinate) are coordinates representing the top and left sides of the bounding box. The width and height values represent the dimensions of the bounding box as a ratio of the overall image dimension. Learn More |
Instances[].BoudingBox.Height | Height of the bounding box as a ratio of the overall image height. |
Instances[].BoudingBox.Width | Width of the bounding box as a ratio of the overall image width. |
Instances[].BoudingBox.Top | Top coordinate of the bounding box as a ratio of the overall image height. |
Instances[].BoudingBox.Left | Left coordinate of the bounding box as a ratio of the overall image width. |
Parents[] | A parent label for a label. A label can have 0, 1, or more parents. |
Parents[].Name | The name of the parent label. Each parent label is represented by a JSON object that contains the name. |
Overall, the Context API Response
provides information about the labels detected in the media content, along with their location, confidence level, and any parent labels that may be relevant. This information can be used to perform various tasks such as image classification, content moderation, and object recognition.
To learn more about this transformation, click here.