ProductAI® SDKs enable using ProductAI® APIs easily in the programming language of your choice. You can use our Python SDK to send image queries and maintain your datasets.
$ pip install productai
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.add_image(url, meta, tags='cartoon|square')
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
with open('images.csv') as f:
res = api.add_images_in_bulk(f)
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
with open("images.csv") as f:
resp = api.delete_images_in_bulk(f)
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_creating_api()
resp = api.create_image_set(name='xxx', description='xxx')
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.get_image_set()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.update_image_set(name="xxx")
or
resp = api.update_image_set(description="xxx")
or
resp = api.update_image_set(name="xxx", description="xxx")
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.delete_image_set()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
# scenario must be supported by system
resp = api.create_service(name='xxx', scenario='fashion')
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_search_api(service_id)
# query by url of image
resp = api.query(image_url)
# or query by local image
with open("fashion.jpg") as f_image:
resp = api.query(f_image)
# Specifies the maximum number of results, defaults is 20
# Specifies the result containing 'MALE' and 'SHOES' tags
resp = api.query(image_url, count=10, tags=['MALE', 'SHOES'])
# use string as tag search. "|" equals to "and"
resp = api.query(image_url, count=10, tags='MALE|SHOES')
# use the complex form of tag search
resp = api.query(image_url, count=10, tags={'and': ['MALE', 'SHOES', {'or': ['TMALL', 'TAOBAO']}]})
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_customer_service_api(service_id)
resp = api.get_service()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_customer_service_api(service_id)
resp = api.update_service("xxx")
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_customer_service_api(service_id)
resp = api.delete_service()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_api(service_type, service_id)
resp = api.query(image_url)
from productai import Client
# default value is: https://api.productai.cn
cli = Client(access_key_id, access_key_secret, url_root='https://api-bj.productai.cn')
or
cli = Client(access_key_id, access_key_secret)
cli.url_root = 'https://api-bj.productai.cn'
$ pip install productai
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.add_image(url, meta, tags='卡通|四方')
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
with open('images.csv') as f:
res = api.add_images_in_bulk(f)
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
with open("images.csv") as f:
resp = api.delete_images_in_bulk(f)
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_creating_api()
resp = api.create_image_set(name='xxx', description='xxx')
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.get_image_set()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.update_image_set(name="xxx")
or
resp = api.update_image_set(description="xxx")
or
resp = api.update_image_set(name="xxx", description="xxx")
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
resp = api.delete_image_set()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_set_api(image_set_id)
# scenario 必须是系统支持的名字
resp = api.create_service(name='xxx', scenario='fashion')
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_image_search_api(service_id)
# 用图片URL查询
resp = api.query(image_url)
# 或者直接上传本地图片查询
with open("fashion.jpg") as f_image:
resp = api.query(f_image)
# 指定查询结果数量上限,默认为 20
# 指定查询结果必须有MALE和SHOES标签
resp = api.query(image_url, count=10, tags=['MALE', 'SHOES'])
# 也可以按如下方式创建标签搜索,"|"等价于"and"操作符
resp = api.query(image_url, count=10, tags='MALE|SHOES')
# 或者使用复杂标签搜索
resp = api.query(image_url, count=10, tags={'and': ['MALE', 'SHOES', {'or': ['TMALL', 'TAOBAO']}]})
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_customer_service_api(service_id)
resp = api.get_service()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_customer_service_api(service_id)
resp = api.update_service("xxx")
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_customer_service_api(service_id)
resp = api.delete_service()
from productai import Client
cli = Client(access_key_id, access_key_secret)
api = cli.get_api(service_type, service_id)
resp = api.query(image_url)
from productai import Client
# 默认值为: https://api.productai.cn
cli = Client(access_key_id, access_key_secret, url_root='https://api-bj.productai.cn')
or
cli = Client(access_key_id, access_key_secret)
cli.url_root = 'https://api-bj.productai.cn'