代码拉取完成,页面将自动刷新
同步操作将从 Yelena/api - 童趣识物prd文档 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# coding: utf-8
# In[22]:
# 百度API_
# encoding:utf-8
import requests
# client_id 为官网获取的AK, client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=sF3jyK0oLkzhXkvi12XFwarl&client_secret=xF2dE9IWYID9Z7zx6QKCW9O9BLN8PXyG'
response = requests.get(host)
if response:
print(response.json())
# In[26]:
# encoding:utf-8
import requests
import base64
'''
动物识别
'''
request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/animal"
# 二进制方式打开图片文件
f = open(r'C:\Users\jane\OneDrive\桌面\大二\rabbit.jpg', 'rb')
img = base64.b64encode(f.read())
params = {"image":img}
access_token = '24.ee2667bcbeda0d798b828d512b18b553.2592000.1613896418.282335-23576914'
request_url = request_url + "?access_token=" + access_token
headers = {
'Content-Type': 'application/json',
}
response = requests.post(request_url, data=params, headers=headers)
if response:
print (response.json())
# In[27]:
# encoding:utf-8
import requests
import base64
'''
植物识别
'''
request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/plant"
# 二进制方式打开图片文件
f = open(r'C:\Users\jane\OneDrive\桌面\flower.jpg', 'rb')
img = base64.b64encode(f.read())
params = {"image":img}
access_token = '24.ee2667bcbeda0d798b828d512b18b553.2592000.1613896418.282335-23576914'
request_url = request_url + "?access_token=" + access_token
headers = {
'Content-Type': 'application/json',
}
response = requests.post(request_url, data=params, headers=headers)
if response:
print (response.json())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。