![](/img/trans.png)
[英]IBM Watson Visual Recognition Error: Nameless classifier ID not working
[英]How to create a class (not a classifier) with a variable in IBM Watson Visual Recognition with Python?
我正在嘗試使用API創建一個新類,如API文檔https://cloud.ibm.com/apidocs/visual-recognition?code=python#update-a-classifier中所示。
Watson用作類名稱的部分是“_positive_examples”的前綴。 我需要使用變量的內容作為前綴,但它是一個關鍵字,我不能在那里添加任何變量(代碼中的variableNotWorking)。
我曾嘗試將其格式化為字符串,並在Python中創建字典並將其引入其中,但我始終從Python或Watson獲取錯誤。
positive = nuevaClase + '_positive_examples'
visual_recognition = credencials()
with open(aprDirFitxer1, 'rb') as nuevaClase:
updated_model = visual_recognition.update_classifier(
classifier_id=classifId,
positive_examples={positive : nuevaClase}).get_result()
我總是獲得的Watson的錯誤是:
watson_developer_cloud.watson_service.WatsonApiException: Error: Cannot execute learning task. Did not find any files to process in the POST request body. , Code: 400
我認為您的問題可能是您使用的是舊版本的SDK,因為軟件包名稱在版本3中更改為“ibm-watson”。 您需要安裝新的SDK包
pip install --upgrade ibm-watson
然后在您的Python代碼中,從這個新包導入:
from ibm_watson import VisualRecognitionV3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.