1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > [实操]通过调用百度开放平台 实现AI图像识别.

[实操]通过调用百度开放平台 实现AI图像识别.

时间:2023-02-10 16:24:22

相关推荐

[实操]通过调用百度开放平台 实现AI图像识别.

#!/usr/bin/python# -*- coding: UTF-8 -*-from aip import AipImageClassify""" 你的 APPID AK SK """APP_ID = '你的appid'API_KEY = '你的百度KEY'SECRET_KEY = '你的加密key'client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)#####################################################""" 读取图片 """def get_file_content(filePath):with open(filePath, 'rb') as fp:return fp.read()image = get_file_content(r'D:\pyprogram\sources\caomei.jpg')""" 调用通用物体识别 """client.advancedGeneral(image);""" 如果有可选参数 """options = {}options["baike_num"] = 5""" 带参数调用通用物体识别 """result=client.advancedGeneral(image, options)print("1###################.通用物体结果:"+str(result)+'\n')#######################################################""" 读取图片 """def get_file_content(filePath):with open(filePath, 'rb') as fp:return fp.read()image = get_file_content(r'D:\pyprogram\sources\shizitou.jpg')""" 调用菜品识别 """client.dishDetect(image);""" 如果有可选参数 """options = {}options["top_num"] = 3options["filter_threshold"] = "0.7"options["baike_num"] = 5""" 带参数调用菜品识别 """result=client.dishDetect(image, options)print("2###################.菜品结果:"+str(result)+'\n')#######################################################""" 读取图片 """def get_file_content(filePath):with open(filePath, 'rb') as fp:return fp.read()image = get_file_content(r'D:\pyprogram\sources\hongjiu.png')""" 调用红酒识别 """result=client.redwine(image);print("3###################.红酒结果:"+str(result)+'\n')#######################################################""" 读取图片 """def get_file_content(filePath):with open(filePath, 'rb') as fp:return fp.read()image = get_file_content(r'D:\pyprogram\sources\zhibi.jpg')""" 调用货币识别 """result=client.currency(image);print("4#################.纸币金额:"+str(result)+"\n")#######################################################""" 读取图片 """def get_file_content(filePath):with open(filePath, 'rb') as fp:return fp.read()image = get_file_content(r'D:\pyprogram\sources\car.jpg')""" 调用车辆识别 """client.carDetect(image);""" 如果有可选参数 """options = {}options["top_num"] = 3options["baike_num"] = 5""" 带参数调用车辆识别 """reslut=client.carDetect(image, options)print("5.汽车识别情况###################"+str(reslut)+"\n")#######################################################

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。