【问题标题】:Watson Visual-Recognition not using custom classifierWatson Visual-Recognition 不使用自定义分类器
【发布时间】:2017-03-23 13:47:17
【问题描述】:

我正在使用 Watson Visual Recognition 并已成功创建自定义分类器。分类器显示它已准备就绪,状态如下:

{
"classifier_id": "paintings_----",
"name": "paintings",
"owner": "--- owner id -----",
"status": "ready",
"created": "2016-11-09T14:55:45.835Z",
"classes": [
    {"class": "water"},
    {"class": "collage"},
    {"class": "forest"},
    {"class": "beach"},
    {"class": "still"},
    {"class": "abstract"},
    {"class": "building"},
    {"class": "garden"}
],
"retrained": "2016-11-09T15:11:50.740Z"
}

我正在执行以下 curl 命令来测试这个分类器:

curl -X POST -F "images_file=@IMG_5309.JPG" -F "parameters=@paintings.json" "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classify?api_key={valid API key}&version=2016-05-20&threshold=0.0"

而painting.json文件的内容如下:

{
"parameters":{
  "classifier_ids": [
     "water",
     "collage",
     "forest",
     "beach",
     "still",
     "abstract",
     "building",
     "garden"
    ] ,
  "owner":"me",
  "threshold":".5"
 }
}

运行此查询将返回以下结果:

{
"custom_classes": 0,
"images": [
    {
        "classifiers": [
            {
                "classes": [
                    {
                        "class": "vegetation",
                        "score": 1.0
                    },
                    {
                        "class": "flower",
                        "score": 0.668188,
                        "type_hierarchy": "/products/gifts/flower"
                    },
                    {
                        "class": "purple",
                        "score": 0.268941,
                        "type_hierarchy": "/colors/purple"
                    }
                ],
                "classifier_id": "default",
                "name": "default"
            }
        ],
        "image": "IMG_5309.JPG"
    }
],
"images_processed": 1
}

Visual-Recognition 显然没有使用我的分类器文件,我可能错过了一些非常明显的东西。关于我错过了什么的任何想法?我在这里关注文档:https://www.ibm.com/watson/developercloud/visual-recognition/api/v3/#classify_an_image,其中指出 JSON 参数是:

classifier_ids - 用于对图像进行分类的分类器 ID 数组。

owners - 一个数组,其值为“IBM”和/或“me”,用于指定要运行的分类器。

threshold - 一个浮点值,指定一个类必须在响应中显示的最低分数。

【问题讨论】:

    标签: curl classification visual-recognition


    【解决方案1】:

    您的 painting.json 文件中的数组 classifier_ids 应该有 1 个条目:"paintings_----"(使用数字 id 而不是破折号)而不是类名(水、拼贴画等)。

    因为无法将类名理解为classifier_id,API 会从“默认”通用分类器返回结果(因此字段“custom_classes: 0”)

    此外,owners 字段如果使用应该是复数 - 但是,"owners": "me" 是告诉 API 使用所有自定义分类器并跳过默认分类器的简写。在您的情况下,您确切知道要调用哪个分类器 ID,因此您可以省略 owners 字段。我刚刚仔细检查了文档示例,发现我们需要针对这两个问题修复 API 参考中的示例。

    感谢您在问题中提供所有详细信息,祝您服务顺利!

    【讨论】:

      【解决方案2】:

      @Matt ...文档中似乎存在更大的错误。我尝试了通过-F "parameters=@paintings.json" 调用的JSON 文件的结构。我想到 json 文件的参数元素可能与 curl 语句中的参数标识符重复。我的 json 文件现在看起来像这样:

      {
        "classifier_ids": ["paintings_2--------2"],
        "owners": "me",
        "threshold":"0.0"
      }
      

      这适用于 Bluemix Public 和 Bluemix Dedicated。

      【讨论】:

        【解决方案3】:

        尝试将阈值更改为 0.5。为我工作。不知道为什么。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-09-23
          • 1970-01-01
          • 2017-05-22
          • 1970-01-01
          • 2018-01-13
          • 2017-04-02
          • 2017-05-23
          相关资源
          最近更新 更多