turing可视化搜索和可视化相似推荐python的api库

turing-api的Python项目详细描述


Turing Python库

Turing VisualSearch和VisualSimon推荐的Python API库。rest api文档可以在这里找到:https://api.turingiq.com/doc/

设置

这个包可以通过pip获得,可以使用以下命令安装。

pip3 install turing-api

初始化

visualAPI类导入如下。

fromturing_api.lib.visualAPIimportVisualAPI

可以使用以下参数初始化VisualAPI类。

api_key='your_api_key'# You can get API key when you login at: https://www.turingiq.com/loginmode='live'# the mode can be either `live` or `sandbox`. Default mode is `live`.visual_api=VisualAPI(api_key,mode)

自动翻滚

检测图像中的对象并获取检测对象周围的边界框。

# image_url is required field.image_url="https://example.com/image_url.jpg"# now let's call the API.response=visual_api.autocrop(image_url)

该方法返回的边界框可用于视觉搜索,提高视觉搜索质量。

插入

你需要在我们的索引中插入图片来查询它们。insert函数可以如下编写。

# id is required field.id='some_product_id'# image_url is required field.image_url="https://example.com/image_url.jpg"# filters argument is optional. You can specify upto 3 filters as per example given below.# Filters can be useful when querying images from our index. You can apply any filter# as per your requirement.filters={"filter1":"onefilter","filter2":"twofilter","filter3":"threefilter"}# metadata is optional. You can pass additional information about your image which will be# returned when you query image from our index.metadata={"title":"Image Title"}# now let's call the API.response=visual_api.insert(id,image_url,filters,metadata)

更新

如果需要更新索引图像的信息,可以使用更新功能。如果对尚未建立索引的id调用update函数,它会将图像插入索引。

# id is required field. Provide id for which you need to update the information.id='some_product_id'# image_url is optional field. You can pass `null` if you would like to keep URL unchanged.image_url="https://example.com/image_url.jpg"# filters argument is optional. You can specify upto 3 filters as per example given below.# Filters can be useful when querying images from our index. You can apply any filter# as per your requirement. The filters you provide here will be overwritten.filters={"filter1":"onefilter","filter2":"twofilter","filter3":"threefilter"}# metadata is optional. You can pass additional information about your image which will be# returned when you query image from our index. Existing metadata values will be overwritten# based on keys supplied to this array.metadata={"title":"Image Title"}# now let's call the API.response=visual_api.update(id,image_url,filters,metadata)

删除

使用此方法可以从索引中删除图像。

# id is required field.id='some_product_id'# now let's call the API.response=visual_api.delete(id)

视觉搜索

可视化搜索可用于基于查询图像搜索索引图像。

# image_url is required field. The API will perform visual search on the image and returnimage_url="https://example.com/image_url.jpg"# crop_box is optional field. You can supply empty array if you don't want to specify crop box.# The format of crop box is [xmin, ymin, xmax, ymax]crop_box=[188,256,656,928]# filters argument is optional. You can specify upto 3 filters.# For example, if you specify filter1 = "nike", it will only return images which are indexed with# "nike" as filter1.filters={"filter1":"nike"}# now let's call the API.response=visual_api.search(image_url,crop_box,filters)

视觉推荐

视觉推荐提供视觉上相似的图像推荐,可用于在电子商务网站上显示推荐小部件,从而大大提高CTR和转换率。

# image_url is required field. The API will perform visual search on the image and returnid="some_product_id"# filters argument is optional. You can specify upto 3 filters.# For example, if you specify filter1 = "nike", it will only return images which are indexed with# "nike" as filter1.filters={"filter1":"nike"}# now let's call the API.response=visual_api.recommendations(id,filters)

运行测试

API_KEY=api_key python3 test/visualAPITest.py

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java从SVG中提取层   java通过蓝牙将文件从手机传输到其他手机   java如何使网络化JavaFX应用程序正确退出?   java Android Open GL不绘制正方形   java为什么使用泛型得到编译器警告?   多集群的Java Hazelcast问题   java OpenCV库配置正确,安卓应用程序可以正常运行一段时间,直到出现错误,表明不再加载该库   java字节好友通知中断Eclipse调试器   java JavaMail不会从发件人(Google除外)检索邮件   java使用MOXy将JsonObject属性映射到XML   java在FilteredTree中搜索“隐藏数据”   Javafx:用鼠标在ImageView上绘图   垃圾收集如何确定Java应用程序年轻gc的原因   java如何维护每个请求打开的Hibernate会话?   java gzip输入文件中的hadoop mapreduce   Java新手:Swing和显示ASCII文件   java RxJava异步订阅   java向editText添加搜索功能   java JavaFX TableViewTextField绑定