如何在IBM Watson Visual Recognition中使用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

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注