Git Product home page Git Product logo

productai-python-sdk's Introduction

ProductAI SDK for Python

https://travis-ci.org/MalongTech/productai-python-sdk.svg?branch=master

ProductAI® SDKs enable using ProductAI® APIs easily in the programming languege of your choice. You can use our Python SDK to send image queries and maintain your datasets.

installation

$ pip install productai

Quick start

Add single image to 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.add_image(url, meta, tags='cartoon|square')

Batch add images to image set

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)

Remove images from image set

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)

Search images

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']}]})

Use other 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)

安装

$ 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_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_api(service_type, service_id)
resp = api.query(image_url)

productai-python-sdk's People

Contributors

alan-zhu avatar suzaku avatar wanghaihan avatar wrenchzc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.