productAI

Fashion Analysis

Fashion Intelligence Analysis Service can analyze images with respect to fashion. The analysis includes:

  1. Find apparel products, the type of these products and their color components in the images
  2. Determine the clothing styles, patterns and other fashion elements from the images, and return them as labels.

Basic Usage

Python

PHP

Java

C#

cURL

from productai import Client

cli = Client(ACCESS_KEY_ID, SECRET_KEY)

# Get the corresponding service API
api = cli.get_api('dressing', '_0000111')

# Call the API with url
resp = api.query('https://yyyy')

# Or call the API with local file
with open("zzzz.jpg", mode='rb') as search:
resp = api.query(search)
use ProductAI;

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

// Call the API with url
$result = $product_ai->classifyImage('dressing', '_0000111', 'https://yyyy');

// Or call the API with local file
$result = $product_ai->classifyImage('dressing', '_0000111', '@zzzz.jpg');
import java.io.File;
import cn.productai.api.core.*;
import cn.productai.api.core.enums.*;
import cn.productai.api.pai.entity.classify.*;

// Set intialize parameters for API
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 the API with url
ClassifyByImageUrlRequest request = new ClassifyByImageUrlRequest(ServiceType.Dressing, "_0000111");
request.setUrl("https://yyyy");

// Or call the API with local file
ClassifyByImageFileRequest request = new ClassifyByImageFileRequest(ServiceType.Dressing, "_0000111");
request.setImageFile(new File("zzzz.jpg"));
request.setLanguage(LanguageType.Chinese);

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 the API with url
var request = new DressingClassifyByImageUrlRequest()
{
Url="http://yyyy",
Language=LanguageType.Chinese
};

// Or call the API with local file
var request = new DressingClassifyByImageFileRequest()
{
ImageFile=new System.IO.FileInfo(@".\zzzz.jpg"),
Language=LanguageType.Chinese
};

var response = client.GetResponse(request);
# Call the API with url
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-d "url=https://yyyy" \
https://api.productai.com/dressing/_0000111

# Or call the API with local file
curl -X POST \
-H 'x-ca-version: 1.0' \
-H 'x-ca-accesskeyid: ACCESS_KEY_ID' \
-F "search=@zzzz.jpg" \
https://api.productai.com/dressing/_0000111

Request

ArgumentTypeDescriptionRequiredLimitation
urlStringURL of query imageYesMutually exclusive with search argument
searchFileContent of query imageYesMutually exclusive with url argument

Response

Return Http Status Code 200, When Success

{
"is_err": 0,
"labels-en": [
"Summer clothing/Autumn clothing",
"Modern",
"jumpsuit-romper",
"Pure",
"Orange",
"White",
"casual"
],
"request_id": "aa28df18-e0bb-11e7-9a73-92019f9dce87",
"results": [
...
],
"time": 2.163
}
FieldTypeDescription
is_errInteger1 means error, and 0 means success
request_idStringUnique request ID, which can be used to debug jointly with ProductAI team
resultsArrayFashion analysis result for one image. For details, see Results Field Detail
labels-enArrayFashion tags in English

Results Field Detail

{
"box": [
0.30526315789473685,
0.16157894736842104,
0.4112280701754386,
0.7268421052631578
],
"colors": [
...
],
"item-en": "jumpsuit-romper",
"textures-en": [
"Pure"
]
}
FieldTypeDescription
boxArrayThe position of the detected product in the image. The format is “x-y-w-h“. The meaning of the four sub-parameters _x_, _y_, _w_ and _h_ is as follows:The coordinate of the upper-left corner of the query image is (0,0),and the coordinate of the lower-right corner is (1, 1),x is the ratio of upper-left x-ordinate of the box to image width, and y is the ration of upper-left y-ordinate of the box to image height, and w is the ratio of box width to image width, and h is the ratio of box height to image height.
colorsArrayColor analysi result. For details, see Colors Field Detail
item-enArrayItem class tag in English
textures-enArrayTexture tag in English

Colors Field Detail

{
"basic-en": "White",
"ncs": "0300-N",
"percent": 0.89457,
"rgb": [
240,
240,
240
],
"w3c-en": "GhostWhite"
},
{
"basic-en": "Orange",
"ncs": "2020-Y60R",
"percent": 0.10543,
"rgb": [
205,
171,
149
],
"w3c-en": "DarkSalmon"
}
FieldTypeDescription
basic-enStringColor name in Basic Naming System in English
w3c-enStringColor name in W3C Naming System in English
ncsStringName of NCS system
percentFloatColor ratio
rgbArrayColor RGB

For color system, please refer to return_type

Return Http Status Code Non-200, When Failed

{
"data": {
"is_err": 1,
"message": "Download image failed.",
"request_id": "de5f84d0-e0bb-11e7-91d5-72f17f92a514",
"time": 0.011
},
"status": 408
}
FieldTypeDescription
dataDictionaryAll information are wrapped inside the data field
statusIntegerHTTP status code
is_errInteger1 means error, and 0 means success
messageStringError Details
request_idStringUnique request ID, which can be used to debug jointly with ProductAI team
timeFloatTime cost in service side

Error Code

SDK/API uses HTTP status code to indicate success or failure of an API call.

HTTP Status Codeerror_codeDescription
200N/aSuccess
400N/aArgument loc is invalid or query image is empty
408N/aQuery image download failed, or query image format parsing failed, or image color analysis failed, or upstream computing service failed

Tags

Possible values of labels-en field

Tags
A_line_loose_dressPolo_shirtTshirtSlim_bottom_skirtWarmSuspender pantsSuspender skirtLongsleeve_dress
Shirt_blouseShirt_dressSports_jacketsSpring_summer_seasonStyle_recommendationTank_strap_topsVolumn_skirtCoat
Shoulder_handbagWinter_clothingCape_coatUrban_casualUrban_eleganceHolidayShortsBooties_short_boots
Canvas_shoesTrenchcoatVintage/retroExperiencedHeel_sandalsClassicalOutdoor_shoppingOutdoor_packet
Active/athleticEnergeticJacketLeisure_wearYouthBodycon_dressClassic_styleLeisure_wear
Social_event/partyCardigansSchool_seasonCuteCulotte_pantsFormal_dressJumpsuit_romperTravel
Wool_coatPadded_jacketLong_jeansWarm_winterFurLeather_loafer_shoesLeatherFlat_sandals
Wedge_shoesChinese_dressWalletsPumpsYouthInnocentFall_winter_seasonFall/spring_season
BackpacksCasualPullover_topsOffice_ladySlippersOutdoorOuterwear_vestHoodies
Sleeveless_topsBall_partyBlazersTailored_pantsSummer_seasonSummer_seasonTallGraceful
SkinnyModernSlim_pants_leggingsSexyVacationLeisure_pantsLeisure_dressSlim_fit
Snow_bootsChiffon_topsWool_sweater_topsSwim_suitsElegantFeminineRainbootsDown_jacket
DatingSneakersFall/spring_seasonFall_winter_seasonKnit_hollow_out_topsIntellectualFeminineBusiness_attire
Mid_long_bootsBusiness_casualSocialFlats_shoesPracticalWaisted_dressClutchFeminine

Possible values of item-en field

Tags
Mid_long_bootsHoodiesPolo_shirtWedge_shoesJumpsuit_romperLeather_loafer_shoesCanvas_shoesRainboots
TrenchcoatSleeveless_topsShirt_dressVolumn_skirtFlat_sandalsChinese_dressBackpacksSuspenderpants
Shoulder_handbagWool_sweater_topsHeel_sandalsLong_jeansSuspenderskirtDown_jacketOutdoor_packetPadded_jacket
PumpsSlim_bottom_skirtSneakersCardigansBooties_short_bootsWaisted_dressOuterwear_vestShorts
Culotte_pantsSwim_suitsLeisure_dressBlazersSlim_pants_leggingsA_line_loose_dressCape_coatKnit_hollow_out_tops
Bodycon_dressPullover_topsSlippersFlats_shoesLeisure_pantsShirt_blouseFurLeather
Sports_jacketsChiffon_topsTailored_pantsLongsleeve_dressJacketTshirtClutchWool_coat
Formal_dressSnow_bootsTank_strap_topsCoatWallets

Possible values of texture-en field

Tags
StripeGeometricPlaidLettersAnimalsCamoHumanFloral
PrintingContrastCartoonPolkadotsLeopardPure