python 菜品识别_菜品识别-python

直接上代码,用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
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值