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')
""" 調(diào)用菜品識(shí)別 """
client.dishDetect(image);
""" 如果有可選參數(shù) """
options = {}
options["top_num"] = 10
options["filter_threshold"] = "0.7"
options["baike_num"] = 1
""" 帶參數(shù)調(diào)用菜品識(shí)別 """
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': '時(shí)令小菜', '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'}
然后取值即可,有什么問題留言即可,
總結(jié)
以上是生活随笔為你收集整理的python 菜品识别_菜品识别-python的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ACM知识竞)赛 之 SDUT3034
- 下一篇: websocket python爬虫_p