from aip import AipImageClassify
from PIL import Image, ImageDraw, ImageFont

# 填写你的图像识别应用的App ID、API Key、Secret Key
APP_ID = ''
API_Key = ''
Secret_Key = ''
client = AipImageClassify(APP_ID, API_Key, Secret_Key)
# 读取图片数据
fileName = input('输入图片文件名:')
fileName = './image/' + fileName
with open(fileName, 'rb') as fp:
    img = fp.read()
# 调用动物识别接口
result = client.animalDetect(img, {"top_num": 3})
result = result['result']
img = Image.open(fileName)
font = ImageFont.truetype('c:/windows/Fonts/simsun.ttc', 24)
draw1 = ImageDraw.Draw(img)
prtStr = ''
for item in result:
    prtStr = prtStr + "%s\t%s\n" % (item['name'], item['score'])
draw1.text((5, 5), prtStr, fill='red', font=font)
img.show()
