菜品识别+表格
这是真希望 发布于2020-12 浏览:1128 回复:1
0
收藏
快速回复

from aip import AipImageClassify
import os,time
from openpyxl import Workbook
""" 你的 APPID AK SK """
APP_ID = '*'
API_KEY = '*'
SECRET_KEY = '*'

client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)

folder_path = './1'
image_list = os.listdir(folder_path)
result_list = [["图片名","菜名","卡路里"]]


""" 读取图片 """
for fn in image_list:
filename = './1/' + fn
fo = open(filename,'rb')
img = fo.read()
fo.close()

options = {}
options["filter_threshold"] = "0.6"
""" 调用菜品识别 """
result = client.dishDetect(img,options);
print(fn,
'菜品名:' + result["result"][0]["name"],
'卡路里:' + result["result"][0]["calorie"])

result_list.append(( '图件名:'+fn,
'菜品名:' + result["result"][0]["name"],
'卡路里:' + result["result"][0]["calorie"]))
time.sleep(0.5)
wb = Workbook()
sheet = wb.active
for row in result_list:
sheet.append(row)
wb.save("result.xlsx")

收藏
点赞
0
个赞
共1条回复 最后由wangwei8638回复于2020-12
#2wangwei8638回复于2020-12

直接输出表格?

0
TOP
切换版块