直接上代码,用python写的
from aip import AipImageClassify """ 你的 APPID AK SK """ APP_ID = '自己id' API_KEY = '自己ak' SECRET_KEY = '自己sk' 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('1.jpg') """ 调用菜品识别 """ client.dishDetect(image); """ 如果有可选参数 """ options = {} options["top_num"] = 10 options["filter_threshold"] = "0.7" options["baike_num"] = 1 """ 带参数调用菜品识别 """ res = client.dishDetect(image, options) #print (res) for k in res: print ("%s->%s"%(k,res[k])) #for value in res.values(): # print(value)
输出的值在下面↓
log_id->2672950373429050871 result_num->10 result->[{'calorie': '8', 'has_calorie': True, 'baike_info': {}, 'probability': '0.13639', 'name': '油麦菜'}, {'calorie': '16', 'has_calorie': True, 'name': '黄瓜', 'probability': '0.125964'}, {'calorie': '41', 'has_calorie': True, 'name': '炒青菜', 'probability': '0.0669439'}, {'calorie': '22', 'has_calorie': True, 'name': '芥兰', 'probability': '0.0554446'}, {'calorie': '13', 'has_calorie': True, 'name': '时令小菜', 'probability': '0.0486102'}, {'calorie': '32', 'has_calorie': True, 'name': '开胃小菜', 'probability': '0.0421106'}, {'calorie': '35', 'has_calorie': True, 'name': '白灼菜心', 'probability': '0.0379339'}, {'has_calorie': False, 'name': '素凉菜', 'probability': '0.0372788'}, {'calorie': '45', 'has_calorie': True, 'name': '秋葵', 'probability': '0.0285839'}, {'calorie': '41', 'has_calorie': True, 'name': '烧青菜', 'probability': '0.0215327'}
然后取值即可,有什么问题留言即可,
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
是urllib3版本问题,更换了就不会了,之前是26版本
pip install urllib3==1.25.11
File "D:\Program Files\Python\Python37\lib\ssl.py", line 810, in _create
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname
我的报这个错误,是本地环境问题吗?