我正在使用视觉识别curl命令向图像添加分类:
curl -u "user":"password" \
-X POST \
-F "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92fbfff3f5f7e1cdf4fbfef7afd2fbfff3f5f7a2bcf8e2f5" rel="noreferrer noopener nofollow">[email protected]</a>" \
-F "classifier_ids=classifierlist.json" \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers?version=2015-12-02"
json 文件:
{
"classifiers": [
{
"name": "tomato",
"classifier_id": "tomato_1",
"created": "2016-03-23T17:43:11+00:00",
"owner": "xyz"
}
]
}
(也尝试过不使用分类器数组。得到相同的错误) 并收到错误: {“code”:400,“error”:“无法执行学习任务:未给出分类器名称”}
json有问题吗?
最佳答案
要指定要使用的分类器,您需要发送类似于以下内容的 JSON 对象:
{"classifier_ids": ["Black"]}
在 CURL 中使用 Black
作为分类器 ID 的示例:
curl -u "user":"password" \
-X POST \
-F "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84ede9e5e3e1f7dbe2ede8e1b9c4ede9e5e3e1b4aaeef4e3" rel="noreferrer noopener nofollow">[email protected]</a>" \
-F "classifier_ids={\"classifier_ids\":[\"Black\"]}"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
如果您想在 JSON 文件中列出分类器 ID,则:
curl -u "user":"password" \
-X POST \
-F "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d6bfbbb7b1b3a589b0bfbab3eb96bfbbb7b1b3e6f8bca6b1" rel="noreferrer noopener nofollow">[email protected]</a>" \
-F "classifier_ids=@classifier_ids.json"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
其中classifier_ids.json
具有:
{
"classifier_ids": ["Black"]
}
您可以在 API Explorer 中测试视觉识别 API .
了解有关该服务的更多信息 documentation .
关于ibm-cloud - 视觉识别错误 400 : Cannot execute learning task no classifier name given,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36189964/