from aip import AipImageClassify APP_ID = 'baidu_id' API_KEY = 'baiodu_key' SECRET_KEY = 'baidu_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('2.jpg') result = client.advancedGeneral(image);# 定義參數變量
print(result) ##python3 這里會顯示為中文 print str(result).decode('unicode_escape') ##python2 需要轉化下,否則顯示為u'\u6cd5\u5170' 類型字符串。
u'name': u'\u5e03\u9c81\u585e\u5c14\u683c\u91cc\u82ac\u72ac'}]}
###############other############################
options = {}
options["top_num"] = 5 # 輸出前5個可能性預測
# 調用動物分類器
result=client.animalDetect(image,options)
# 調用汽車分類器
result=client.carDetect(image,options)
# """ 調用菜品識別 """
# print(client.dishDetect(image))
# """ 調用logo商標識別 """
# print(client.logoSearch(image))
# """ 調用動物識別 """
# print(client.animalDetect(image))
# """ 調用植物識別 """
# print(client.plantDetect(image))