百度AI實現圖像鑒別-python


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))
print(result)



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM