百度AI中图像识别的调用
(1)首先需要通过API Key和Secret Key获取access_token
输入:
import requests
import base64'''
菜品识别
'''request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v2/dish"
# 二进制方式打开图片文件
f = open('1.jpg', 'rb')
img = base64.b64encode(f.read())params = {"image":img,"top_num":5}
access_token = '24.8b7fed2d558472cb28d9f2e6b7592ee5.2592000.1579144770.282335-18043433'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=https://www.it610.com/article/params, headers=headers)
if response:
print (response.json())
输出:
文章图片
菜品识别的输出代码 (2 )接着对菜品进行识别
输入:
import requests
import base64'''
菜品识别
'''request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v2/dish"
# 二进制方式打开图片文件
f = open('1.jpg', 'rb')
img = base64.b64encode(f.read())params = {"image":img,"top_num":5}
access_token = '24.8b7fed2d558472cb28d9f2e6b7592ee5.2592000.1579144770.282335-18043433'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=https://www.it610.com/article/params, headers=headers)
if response:
print (response.json())
【百度AI中图像识别的调用】输出:
文章图片
菜品识别的输出代码
推荐阅读
- 热闹中的孤独
- Shell-Bash变量与运算符
- JS中的各种宽高度定义及其应用
- 2021-02-17|2021-02-17 小儿按摩膻中穴-舒缓咳嗽
- 深入理解Go之generate
- 异地恋中,逐渐适应一个人到底意味着什么()
- 我眼中的佛系经纪人
- 《魔法科高中的劣等生》第26卷(Invasion篇)发售
- “成长”读书社群招募
- 2020-04-07vue中Axios的封装和API接口的管理