productAI

Object Detection

Detect object location in the image and get object category info

Basic Usage

Python

PHP

Java

C#

cURL

from productai import Client

cli = Client(ACCESS_KEY_ID, SECRET_KEY)

# Get service API context
api = cli.get_api('detect', '_xxxxxxxx')

# Call service with url as input parameter
resp = api.query(image='https://yyyy')

# Call service with local file as input parameter
with open("zzzz.jpg", mode='rb') as search:
resp = api.query(search)
use ProductAI;

// Get service API context
$product_ai = new ProductAI\API(ACCESS_KEY_ID, SECRET_KEY, 'zh-Hans');

// Call service with url as input parameter
$result = $product_ai->detectImage('detect', '_xxxxxxxx', 'https://yyyy');

// Call service with local file as input parameter
$result = $product_ai->detectImage('detect', '_xxxxxxxx', '@zzzz.jpg');
import java.io.File;
import cn.productai.api.core.*;
import cn.productai.api.core.enums.*;
import cn.productai.api.pai.entity.detect.*;

// Set API initializing parameters
IProfile profile = new DefaultProfile();
profile.setAccessKeyId(ACCESS_KEY_ID);
profile.setSecretKey(SECRET_KEY);
profile.setVersion("1");

IWebClient client = new DefaultProductAIClient(profile);

// Call service with url as input parameter
DetectByImageUrlRequest request = new DetectByImageUrlRequest(DetectType.Cloth);
request.setUrl("https://yyyy");

// Call service with local file as input parameter
DetectByImageFileRequest request = new DetectByImageFileRequest(DetectType.Cloth);
request.setImageFile(new File("zzzz.jpg"));

DetectResponse response = client.getResponse(request);
String json = response.getResponseJsonString();
using MalongTech.ProductAI.Core;
using MalongTech.ProductAI.API.Entity;

IProfile profile = new DefaultProfile
{
Version="1",
AccessKeyId=ACCESS_KEY_ID,
SecretKey=SECRET_KEY,
};
var client = new DefaultProductAIClient(profile);

// Query with url
var request = new DetectByImageUrlRequest(DetectType.Cloth)
{
Url="https://yyyy"
};

// Query with local file
var request = new DetectByImageFileRequest(DetectType.Cloth)
{
ImageFile=new System.IO.FileInfo("zzzz.jpg")
};

var response = client.GetResponse(request);
# Call service with url as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_xxxxxxxx

# Call service with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_xxxxxxxx

Note that ‘_xxxxxxxx’ indicates a specific detect service ID, please refer to Services

Request

ArgumentTypeDescriptionRequiredLimitation
urlStringImage urlYesShould specify one of the fields, url or search
searchFileImage fileYesShould specify one of the fields, url or search

Response

Return Http Status Code 200, When Success

{
"boxes_detected": [
...
],
"detecttime": "1.421",
"get_image_time": "0.006",
"image_id": "165145_161136_b79167f0-e166-11e7-bb18-eea500941bf4",
"request_id": "b79167f0-e166-11e7-bb18-eea500941bf4",
"time": "1.430",
"ver": "2.1.5"
}
FieldTypeDescription
detecttimeStringTime cost in seconds on detect service
timeStringTotal time cost in seconds on the whole API service side
get_image_timeStringImage downloaded time
request_idStringThe unique ID of this api call, it can be used in issue debugging with ProductAI support team
boxes_detectedArrayCollection of detected boxes for this image, for details please refer to Image Search - loc Usage

boxes_detected

{
"box": [
0.17477203647416414,
0.025056947608200455,
0.37537993920972645,
0.9453302961275627
],
"puid": "person",
"score": 0.9983668923377991,
"type": "person"
}
FieldTypeDescription
boxStringBounding box info, format is “x-y-w-h”. x,y,w,h means: mark top left corner of image as (0,0), right bottom corner as (1,1), x is bounding-box-left-position/image-width , y is bounding-box-top-position/image-height, w is bounding-box-width/image-width, h is bounding-box-height/image-height
puidStringUnique ID of label category
scoreFloatProbability of output label
typeStringDetecting result category under current language setting

Return Http Status Code Non-200, When Failed

{
"data": {
"error_code": 400004,
"is_err": 1,
"message": "Could not download http://a.com/b.jpg",
"request_id": "e5e16268-e166-11e7-91d5-72f17f92a514"
},
"status": 400
}
FieldTypeDescription
dataDictionaryContains all the fields
statusIntegerHTTP Status Code
is_errInteger1 indicates failure, 0 indicates success
messageStringThe detail error message
request_idStringThe unique ID of this request, this can be leveraged in product issue debugging with ProductAI support team
error_codeIntegerDetailed error code

Error Code

HTTP Status Code is used by SDK/API to notify client whether this api call is success or fail

HTTP Status Codeerror_codeDescription
200N/aSuccess
400400002Request image cannot be decoded
400400003No request image
400400004Image cannot be downloaded
400400008Size of query image is too small, please refer to requirements

Services

Fashion Detection v2.0

Python

PHP

Java

C#

cURL

# Set service ID to _0000173
api = cli.get_api('detect', '_0000173')
// Set service ID to _0000173, call service with URL as input parameter
$result = $product_ai->detectImage('detect', '_0000173', 'https://yyyy');

// Set service ID to _0000173, call service with local file input parameter
$result = $product_ai->detectImage('detect', '_0000173', '@zzzz.jpg');
// Set service to cloth dection, call service with URL as input parameter
DetectByImageUrlRequest request = new DetectByImageUrlRequest("detect", "_0000173", "https://yyyy", "");

// Set service to cloth dection, call service with local file input parameter
DetectByImageFileRequest request = new DetectByImageFileRequest("detect", "_0000173", new File("zzzz.jpg"), "");
// Set service to cloth dection, call service with URL as input parameter
var request = new DetectByImageUrlRequest("detect", "_0000173")
{
Url="https://yyyy"
};

// Set service to cloth dection, call service with local file input parameter
var request = new DetectByImageFileRequest("detect", "_0000173")
{
ImageFile=new System.IO.FileInfo("zzzz.jpg")
};
# Call service with url as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_0000173

# Call service with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_0000173

Tags

Tags
flats-shoesmid-long-bootshoodiespolo-shirtwedge-shoesrainboots
trenchcoattshirtsleeveless-topsshirt-dressvolumn-skirtflat-sandals
qipaobackpacksbeidaikusnow-bootswool-sweater-topsheel-sandals
women-sports-jacketsshoulder-handbagbeidaiqunleather-loafer-shoescanvas-shoesoutdoor-xiaobao
mianfusneakersslim-bottom-skirtcardigansbooties-short-bootsouterwear-vest
shortsdown-jacketleisure-dressjumpsuit-romperwalletsblazers
swim-suitswool-coatcape-coatknit-hollow-out-topsbodycon-dresspullover-tops
waisted-dressleisure-pantsshirt-blousefurculotte-pantsclutch
long-jeansslim-pants-leggingschiffon-topstailored-pants-womenjacketleather
a-line-loose-dresscoatpumpsformal-dresslongsleeve-dress-for-fallslippers
tank-strap-topsjewelleryglassesgoggleswatchbelt
scarfglovecapnon-fashion

Furniture Detection v3.0

Python

PHP

Java

C#

cURL

# Set service ID to _0000171
api = cli.get_api('detect', '_0000171')
// Set service ID to _0000171, call service with URL as input parameter
$result = $product_ai->detectImage('detect', '_0000171', 'https://yyyy');

// Set service ID to _0000171, call service with local file input parameter
$result = $product_ai->detectImage('detect', '_0000171', '@zzzz.jpg');
// Set service ID to _0000171, call service with URL as input parameter
DetectByImageUrlRequest request = new DetectByImageUrlRequest('detect', '_0000171');
request.setUrl("https://yyyy");

// Set service ID to _0000171, call service with local file input parameter
DetectByImageFileRequest request = new DetectByImageFileRequest('detect', '_0000171');
request.setImageFile(new File("zzzz.jpg"));
// Set service ID to _0000171, call service with URL as input parameter
var request = new DetectByImageUrlRequest('detect', '_0000171')
{
Url="https://yyyy"
};

// Set service ID to _0000171, call service with local file input parameter
var request = new DetectByImageFileRequest('detect', '_0000171')
{
ImageFile=new System.IO.FileInfo("zzzz.jpg")
};
# Call service with url as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_0000171

# Call service with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_0000171

Tags

Tags
casamania_pollon_poufcorner_tablefaucettv_cabinettoiletshower_caddy
bathroom_cabinetfloor_lampteapoysofawall_lampchair
bedside_cupboarddesk_lampbedpendant_lamptableceiling-lights
bed_benchreclinertroughdrawer_chestsinkbathtub
bar_stool

Receipt Text Identification v1.0

This service is able to recognize the credit card receipt which is commonly used in China mainland area
Sample Image 1

Python

PHP

Java

C#

cURL

# Set service ID to _0000143
api = cli.get_api('detect', '_0000143')
// Set service ID to _0000143, call service with URL as input parameter
$result = $product_ai->detectImage('detect', '_0000143', 'https://yyyy');

// Set service ID to _0000143, call service with local file input parameter
$result = $product_ai->detectImage('detect', '_0000143', '@zzzz.jpg');
// Set service ID to _0000143, call service with URL as input parameter
DetectByImageUrlRequest request = new DetectByImageUrlRequest("detect", "_0000143", "https://yyyy","0-0-1-1");

// Set service ID to _0000143, call service with local file input parameter
DetectByImageFileRequest request = new DetectByImageFileRequest("detect", "_0000143", new File("zzzz.jpg"),"0-0-1-1");
// Set service ID to _0000143, call service with URL as input parameter
var request = new DetectByImageUrlRequest("detect", "_0000143")
{
Url="https://yyyy"
};

// Set service ID to _0000143, call service with local file input parameter
var request = new DetectByImageFileRequest("detect", "_0000143")
{
ImageFile=new System.IO.FileInfo("zzzz.jpg")
};
# Call service with url as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_0000143

# Call service with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_0000143

Response

{
"boxes_detected": [
{
"score": 0,
"type": "merchant_code",
"value": "821210255110050"
},
{
"score": 0,
"type": "terminal_no",
"value": null
},
{
"score": 0,
"type": "union_pay_merchant_code",
"value": "821210255110050"
},
{
"score": 0,
"type": "amount",
"value": "2300000.00"
}
],
"detecttime": "2.354",
"image_id": "185227_676779_27e4a8133a0a349ed286fc85e6e733a80051f695",
"request_id": "3022fc7e-e2e8-11e7-914b-9e715a41c4bb",
"time": "2.360",
"ver": "1.3.7"
}
FieldTypeDescription
scoreIntegerAll 0, please ignore at this moment
typeStringRecognized text type
valueStringRecognized text

Face Detection v1.0

Python

PHP

Java

C#

cURL

# Set service ID to _0000049
api = cli.get_api('detect', '_0000049')
// Set service ID to _0000049, call service with URL as input parameter
$result = $product_ai->detectImage('detect', '_0000049', 'https://yyyy');

// Set service ID to _0000049, call service with local file input parameter
$result = $product_ai->detectImage('detect', '_0000049', '@zzzz.jpg');
// Set service ID to _0000049, call service with URL as input parameter
DetectByImageUrlRequest request = new DetectByImageUrlRequest("detect", "_0000049", "https://yyyy", "0-0-1-1");

// Set service ID to _0000049, call service with local file input parameter
DetectByImageFileRequest request = new DetectByImageFileRequest("detect", "_0000049", new File("zzzz.jpg"), "0-0-1-1");
// Set service ID to _0000049, call service with URL as input parameter
var request = new DetectByImageUrlRequest("detect", "_0000049")
{
Url="https://yyyy"
};

// Set service ID to _0000049, call service with local file input parameter
var request = new DetectByImageFileRequest("detect", "_0000049")
{
ImageFile=new System.IO.FileInfo("zzzz.jpg")
};
# Call service with url as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_0000049

# Call service with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_0000049

Tags

Tags
face

Human Body Detection v1.0

Python

PHP

Java

C#

cURL

#Set service ID to _0000059
api = cli.get_api('detect', '_0000059')
//Set service ID to _0000059, call service with URL as input parameter
$result = $product_ai->detectImage('detect', '_0000059', 'https://yyyy');

//Set service ID to _0000059, call service with local file input parameter
$result = $product_ai->detectImage('detect', '_0000059', '@zzzz.jpg');
//Set service ID to _0000059, call service with URL as input parameter
DetectByImageUrlRequest request = new DetectByImageUrlRequest("detect", "_0000059", "https://yyyy", "0-0-1-1");

//Set service ID to _0000059, call service with local file input parameter
DetectByImageFileRequest request = new DetectByImageFileRequest("detect", "_0000059", new File("zzzz.jpg"), "0-0-1-1");
// Set service ID to _0000059, call service with URL as input parameter
var request = new DetectByImageUrlRequest("detect", "_0000059")
{
Url="https://yyyy"
};

// Set service ID to _0000059, call service with local file input parameter
var request = new DetectByImageFileRequest("detect", "_0000059")
{
ImageFile=new System.IO.FileInfo("zzzz.jpg")
};
# Call service with url as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_0000059

# Call service with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_0000059

Tags

Tags
person

Logo Detection v2.0

Detect all brand logos from products in the image, return all brand logos’ position information and brand tags

Python

PHP

Java

C#

cURL

# _0000188 is the ID of logo detection service
api = cli.get_api('detect', '_0000188')
// _0000188 is the ID of logo detection service, call service with image url as input
$result = $product_ai->detectImage('detect', '_0000188', 'https://yyyy');

// _0000188 is the ID of logo detection service, call service with local image file as input
$result = $product_ai->detectImage('detect', '_0000188', '@zzzz.jpg');
// _0000188 is the ID of logo detection service, call service with image url as input
DetectByImageUrlRequest request = new DetectByImageUrlRequest("detect", "_0000188", "https://yyyy", "0-0-1-1");

// _0000188 is the ID of logo detection service, call service with local image file as input
DetectByImageFileRequest request = new DetectByImageFileRequest("detect", "_0000188", new File("zzzz.jpg"), "0-0-1-1");
// _0000188 is the ID of logo detection service, call service with image url as input
var request = new DetectByImageUrlRequest('detect', "_0000188")
{
Url = "https://yyyy",
};

// _0000188 is the ID of logo detection service, call service with local image file as input
var request = new DetectByImageFileRequest('detect', "_0000188")
{
ImageFile = new System.IO.FileInfo(@"zzzz.jpg"),
};

curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/detect/_0000188

curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: eACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/detect/_0000188

Tags

Click here to download the list.