productAI

General Tagging

ProductAI will output multiple tags representing the various general objects and concepts found in the image you provide. You can upload any style of image to this service, for example, try stock photography, street photo, or vector graphic.

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('classify', '_0000159')

# Call API with URL as input parameter
resp = api.query('https://yyyy', count=1)

# Call API with local file as input parameter
with open("zzzz.jpg", mode='rb') as search:
resp = api.query(search)
use ProductAI;
$product_ai = new ProductAI\API(ACCESS_KEY_ID, SECRET_KEY);

// Call API with URL as input parameter
$result = $product_ai->classifyImage('classify', '_0000159', 'http://yyyy');

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

IProfile profile = new DefaultProfile();
profile.setAccessKeyId(ACCESS_KEY_ID);
profile.setSecretKey(SECRET_KEY);
profile.setVersion("1");
profile.setGlobalLanguage(LanguageType.Chinese);
IWebClient client = new DefaultProductAIClient(profile);

// Call service with url as input parameter
ClassifyByImageUrlRequest request = new ClassifyByImageUrlRequest(ServiceType.Classify, "_0000159");
request.setUrl("https://yyyy");

// Call API with local file as input parameter
ClassifyByImageFileRequest request = new ClassifyByImageFileRequest(ServiceType.Classify, "_0000159");
request.setImageFile(new File("zzzz.jpg"));

ClassifyResponse 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,
GlobalLanguage = LanguageType.Chinese
};
var client = new DefaultProductAIClient(profile);

// Call API with URL as input parameter
var request = new ClassifyByImageUrlRequest('classify', "_0000159")
{
Url = "https://yyyy",
};

// Call API with local file as input parameter
var request = new ClassifyByImageFileRequest('classify', "_0000159")
{
ImageFile = new System.IO.FileInfo(@"zzzz.jpg"),
};

var response = client.GetResponse(request);
# Call API with URL as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d 'url=http://xxx.jpg' \
https://api.productai.com/classify/_0000159

# Call API with local file as input parameter
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d 'search=@zzzz.jpg' \
https://api.productai.com/classify/_0000159

Request

ArgumentTypeDescriptionRequiredLimitation
urlStringImage urlYesShould specify one of the fields, url or search
searchFileImage fileYesShould specify one of the fields, url or search
countIntegerTag count to returnNo20 by default

Response

Return Http Status Code 200, When Success

{
"is_err": 0,
"request_id": "5e0c705c-e09f-11e7-91d5-72f17f92a514",
"results": [
{
"category": "indoor",
"puid": "indoor",
"score": 0.9736321524042493
},
{
"category": "food食物",
"puid": "food",
"score": 0.9712933092798621
},
{
"category": "half-length photo",
"puid": "half-length photo",
"score": 0.9630682046079396
},
{
"category": "close shot",
"puid": "close shot",
"score": 0.9563565643119167
},
{
"category": "flat view",
"puid": "flat view",
"score": 0.9489112115335308
}
],
"time": 0.3276219367980957
}
FieldTypeDescription
is_errInteger1 indicates failure, 0 indicates success
request_idStringThe unique ID of this api call, it can be leverage in issue debuggin with ProductAI support team
resultsArrayContains all the tags detected
categoryStringLabel text under current language setting
puidStringUnique ID of tag
scoreFloatProbability of this tag
timeFloatTime cost in seconds on server side

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
400N/aQuery image url is not specified

Tags

Click here to download the list. If you need to switch tag languages, please refer to Languages.