• 菜品识别 SDK调用


     1 from aip import AipImageClassify
     2 import os
     3 
     4 
     5 """ 填入参数 """
     6 APP_ID = 'your APP_ID'
     7 API_KEY = 'your API_KEY'
     8 SECRET_KEY = 'your SECRET_KEY'
     9 client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)
    10 
    11 
    12 """ 读取图片 """
    13 def get_file_content(filePath):
    14     with open(filePath, 'rb') as fp:
    15         return fp.read()
    16 
    17 
    18 def dish_Detect():
    19     dish_path = os.getcwd()
    20     dish_path = dish_path + '/dish'
    21     folderlist = os.listdir(dish_path)
    22     for folder in folderlist:
    23         filePath=dish_path + '/'+folder
    24         image = get_file_content(filePath)
    25         """ 调用菜品识别 """
    26         results=client.dishDetect(image)
    27         result = results['result'][0]
    28         print(folder,
    29               '	菜品为:',result['name'],
    30               '	置信度:', result['probability'],
    31               '	卡路里:', result['calorie'])
    32 
    33 if __name__ == '__main__':
    34     dish_Detect()

    AipImageClassify是图像识别的Python SDK客户端

    首先pip install baidu_aip

  • 相关阅读:
    01 网络基础
    01 ansible的基本介绍
    10 面向对象的编程
    03 docker容器镜像基础
    09 异常处理
    08 输入输出
    07 数据结构
    02 docker的基本用法
    01 docker容器技术基础入门
    06 字符串
  • 原文地址:https://www.cnblogs.com/cekong/p/10174131.html
Copyright © 2020-2023  润新知