(1)首先需要通过API Key和Secret Key获取access_token
调用:
import requests
import base64
'''
相似图检索—入库
'''
request_url = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined"
f = open('1.jpg', 'rb')
img = base64.b64encode(f.read())
params = params
access_token = '24.0becef4766a702132426a128bcc54ed9.2592000.1597595660.282335-21446950'
image = 1
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=params, headers=headers)
if response:
print (response.json())
输出:
{'conclusion': '合规', 'log_id': 15950043563395027, 'conclusionType': 1}
网友评论