Object Recognition
Recognize objects in the image and return the region information and confidence score for each object. 300 types of objects are supported.
Applicable scenarios
Applicable to IPC image detection, target detection and tracking in image scenes for traffic, security and other industries.
List of supported object recognition
The following is a list of supported entities for target detection.
ID |
---|
accordion |
airplane |
alligator |
apple |
army_tank |
awning |
backpack |
ball |
balloon |
banana |
barrel |
baseball |
baseball_bat |
baseball_glove |
basket |
bathtub |
bear |
bed |
bee |
beer_bottle |
bell_pepper |
belt |
bench |
bicycle |
billboard |
bird |
blackboard |
boat |
book |
bookcase |
boot |
bottle |
bowl |
bowling_ball |
box |
bracelet |
brassiere |
bread |
broccoli |
building |
bus_(vehicle) |
butterfly |
cabinet |
cake |
camel |
camera |
can |
candle |
candy_bar |
cannon |
canoe |
car_(automobile) |
carrot |
cart |
castle |
cat |
caterpillar |
cello |
cellular_telephone |
chair |
chicken_(animal) |
chopping_board |
chopstick |
christmas_tree |
clock |
coat |
cocktail |
coffee_table |
coin |
computer_keyboard |
computer_monitor |
cone |
cookie |
cow |
cowboy_hat |
crab_(animal) |
crown |
cucumber |
cup |
cupboard |
curtain |
deer |
desk |
dessert |
dinosaur |
dog |
doll |
dolphin |
door |
doorknob |
doughnut |
dragonfly |
drawer |
dress |
drum_(musical_instrument) |
duck |
duffel_bag |
eagle |
earring |
egg |
elephant |
fan |
faucet |
fireplace |
fireplug |
fish |
flag |
flower_arrangement |
flowerpot |
football_helmet |
fork |
fountain |
french_fries |
frisbee |
frog |
fruit |
fruit_juice |
frying_pan |
gazelle |
giraffe |
glass_(drink_container) |
glove |
goat |
goggles |
goose |
grape |
guitar |
gun |
hamburger |
hamster |
handbag |
handle |
harbor_seal |
hat |
headset |
helicopter |
helmet |
high_heels |
hog |
horse |
house |
icecream |
insect |
jacket |
jaguar |
jean |
jellyfish |
kitchen_table |
kite |
knife |
ladder |
lamp |
lantern |
laptop_computer |
lavender |
lemon |
lettuce |
license_plate |
life_jacket |
lightbulb |
lighthouse |
lily |
lion |
lizard |
maple |
mask |
microphone |
microwave_oven |
minivan |
mirror |
monkey |
motorcycle |
mouse_(computer_equipment) |
muffin |
mug |
mushroom |
musical_instrument |
napkin |
necklace |
necktie |
nightstand |
onion |
orange_(fruit) |
oven |
owl |
paddle |
painting |
palm_tree |
parachute |
parking_meter |
parrot |
pasta |
pastry |
pen |
penguin |
person |
piano |
pillow |
pizza |
plastic_bag |
plate |
polar_bear |
pool_table |
porch |
poster |
potted_plant |
pumpkin |
rabbit |
refrigerator |
remote_control |
ring |
roller_skate |
rose |
salad |
sandal_(type_of_shoe) |
sandwich |
saucer |
saxophone |
scarf |
scissors |
sculpture |
sheep |
shirt |
shoe |
short_pants |
shrimp |
sink |
skateboard |
ski |
skirt |
skullcap |
snake |
snowboard |
soccer_ball |
sock |
sofa |
sofa_bed |
sparrow |
speaker_(stero_equipment) |
spectacles |
spider |
spoon |
sportswear |
squirrel |
stool |
stop_sign |
stove |
straw_(for_drinking) |
strawberry |
street_sign |
streetlight |
suit_(clothing) |
suitcase |
sunflower |
sunglasses |
sunhat |
surfboard |
sushi |
swimming_pool |
swimsuit |
table |
tablet_computer |
taxi |
teddy_bear |
telephone |
television_set |
tennis_ball |
tennis_racket |
tent |
tiger |
toilet |
toilet_tissue |
tomato |
toothbrush |
towel |
tower |
toy |
traffic_light |
train_(railroad_vehicle) |
trash_can |
tray |
tree |
tripod |
trousers |
truck |
trumpet |
turtle |
umbrella |
vase |
vegetables |
violin |
wall_socket |
watch |
water_jug |
whale |
wheel |
wheelchair |
window |
wineglass |
zebra |
API reference
-
HTTP request method:
POST
-
Request body parameters
Name | Type | Required | Description |
---|---|---|---|
url | String | Choose url or img. | Image URL address, which supports HTTP/HTTPS and S3 protocols. Supported image formats are jpg/jpeg/png/bmp, with the longest side not exceeding 4096px. |
img | String | Choose url or img. | Base64 encoded image data. |
- Example JSON request
{
"url": "Image URL address"
}
{
"img": "Base64-encoded image data"
}
- Response parameters
Name | Type | Description |
---|---|---|
Labels | List | List of recognized objects in the image |
Name | String | Target category |
Instances | List | List of category instances |
BoundingBox | JSON | Coordinate value of the instance in the image, including the percentage of top, left, width, height relative to the full screen |
Confidence | Float | Instance confidence, which is from 0 to 100 |
Confidence | Int | Maximum value of current class instance confidence |
LabelModelVersion | String | Current model version number |
- Example JSON response
{
"Labels": [
{
"Name": "car_(automobile)",
"Confidence": 67.87780523300171,
"Instances": [
{
"BoundingBox": {
"Width": 1.0013043403596384,
"Height": 0.9958885181613408,
"Left": -0.00021715163893532008,
"Top": 0.00033918747441136817
},
"Confidence": 67.87780523300171
}
]
},
{
"Name": "mirror",
"Confidence": 59.2678964138031,
"Instances": [
{
"BoundingBox": {
"Width": 0.14041614532470703,
"Height": 0.29166373257057565,
"Left": 0.2743588984012604,
"Top": 0.2794425819140053
},
"Confidence": 59.2678964138031
}
]
},
{
"Name": "window",
"Confidence": 16.396354138851166,
"Instances": [
{
"BoundingBox": {
"Width": 0.44319993257522583,
"Height": 0.6673663154702585,
"Left": 0.5509995222091675,
"Top": 0.015529238811174562
},
"Confidence": 16.396354138851166
}
]
}
],
"LabelModelVersion": "1.2.0"
}
API test
You can use the following tools (API explorer, Postman, cURL, Python, Java) to test calling APIs.
API Explorer
Prerequisites
When deploying the solution, you need to:
- set the parameter API Explorer to
yes
. - set the parameter API Gateway Authorization to
NONE
.
Otherwise, you can only view the API definitions in the API explorer, but cannot test calling API online.
Steps
- Sign in to the AWS CloudFormation console.
-
On the Stacks page, select the solution’s root stack. Do not select the NESTED stack.
-
Choose the Outputs tab, and find the URL for APIExplorer.
-
Click the URL to access the API explorer. The APIs that you have selected during deployment will be displayed.
-
For the API you want to test, click the down arrow to display the request method.
- Choose the Try it out button, and enter the correct Body data to test API and check the test result.
- Make sure the format is correct, and choose Execute.
- Check the returned result in JSON format in the Responses body. If needed, copy or download the result.
- Check the Response headers.
- (Optional) Choose Clear next to the Execute button to clear the request body and responses.
Postman (AWS_IAM Authentication)
- Sign in to the AWS CloudFormation console.
- On the Stacks page, select the solution’s root stack.
- Choose the Outputs tab, and find the URL with the prefix
GeneralOCR
. -
Create a new tab in Postman. Paste the URL into the address bar, and select POST as the HTTP call method.
-
Open the Authorization configuration, select Amazon Web Service Signature from the drop-down list, and enter the AccessKey, SecretKey and Amazon Web Service Region of the corresponding account (such as cn-north-1 or cn-northwest-1 ).
-
Open the Body configuration item and select the raw and JSON data types.
- Enter the test data in the Body, and click the Send button to see the corresponding return results.
{
"url": "Image URL address"
}
cURL
- Windows
curl --location --request POST "https://[API_ID].execute-api.[AWS_REGION].amazonaws.com/[STAGE]/object_recognition" ^
--header "Content-Type: application/json" ^
--data-raw "{\"url\": \"Image URL address\"}"
- Linux/MacOS
curl --location --request POST 'https://[API_ID].execute-api.[AWS_REGION].amazonaws.com/[STAGE]/object_recognition' \
--header 'Content-Type: application/json' \
--data-raw '{
"url":"Image URL address"
}'
Python (AWS_IAM Authentication)
import requests
import json
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth
auth = BotoAWSRequestsAuth(aws_host='[API_ID].execute-api.[AWS_REGION].amazonaws.com',
aws_region='[AWS_REGION]',
aws_service='execute-api')
url = 'https://[API_ID].execute-api.[AWS_REGION].amazonaws.com/[STAGE]/object_recognition'
payload = {
'url': 'Image URL address'
}
response = requests.request("POST", url, data=json.dumps(payload), auth=auth)
print(json.loads(response.text))
Python (NONE Authentication)
import requests
import json
url = "https://[API_ID].execute-api.[AWS_REGION].amazonaws.com/[STAGE]/object_recognition"
payload = json.dumps({
"url": "Image URL address"
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"url\":\"Image URL address\"\n}");
Request request = new Request.Builder()
.url("https://xxxxxxxxxxx.execute-api.xxxxxxxxx.amazonaws.com/[STAGE]/object_recognition")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Cost estimation
You are responsible for the cost of using each Amazon Web Services service when running the solution. As of this revision, the main cost factors affecting the solution include.
- Amazon API Gateway calls
- Amazon API Gateway data output
- Amazon CloudWatch Logs storage
- Amazon Elastic Container Registry storage
If you choose an Amazon Lambda based deployment, the factors also include:
- Amazon Lambda invocations
- Amazon Lambda running time
If you choose an Amazon SageMaker based deployment, the factors also include:
- Amazon SageMaker endpoint node instance type
- Amazon SageMaker endpoint node data input
- Amazon SageMaker endpoint node data output
Cost estimation example 1
In AWS China (Ningxia) Region operated by NWCD (cn-northwest-1), process an image of 1MB in 1 second
The cost of using this solution to process the image is shown below:
Service | Dimensions | Cost |
---|---|---|
AWS Lambda | 1 million invocations | ¥1.36 |
AWS Lambda | 10240MB memory, 1 seconds run each time | ¥1134.8 |
Amazon API Gateway | 1 million invocations | ¥28.94 |
Amazon API Gateway | 100KB data output each time, ¥0.933/GB | ¥93.3 |
Amazon CloudWatch Logs | 10KB each time, ¥6.228/GB | ¥62.28 |
Amazon Elastic Container Registry | 0.5GB storage, ¥0.69/GB each month | ¥0.35 |
Total | ¥1237.06 |
Cost estimation example 2
In US East (Ohio) Region (us-east-2), process an image of 1MB in 4 seconds
The cost of using this solution to process this image is shown below:
Service | Dimensions | Cost |
---|---|---|
AWS Lambda | 1 million invocations | $0.20 |
AWS Lambda | 10240MB memory, 1 seconds run each time | $166.7 |
Amazon API Gateway | 1 million invocations | $3.5 |
Amazon API Gateway | 100KB data output each time, $0.09/GB | $9 |
Amazon CloudWatch Logs | 10KB each time, $0.50/GB | $5 |
Amazon Elastic Container Registry | 0.5GB存储,$0.1/GB each month | $0.05 |
Total | $176.35 |
Uninstall the deployment
You can uninstall the Object Recognition feature via Amazon CloudFormation as described in Add or remove AI features and make sure the ObjectRecognition parameter is set to no in the parameters section.
Note
Time to uninstall the deployment is approximately: 10 Minutes