首页 > 解决方案 > 如何为 deeplab 图像分割模型获取 json 格式的预测输出

问题描述

我已经在 TF1.15 上训练了一个 deeplab 模型。现在,当我在模型中输入图像时,它会给出一个分段掩码。 在此处输入图像描述 在此处输入图像描述

但是现在想要以 json 格式进行预测但无法做到!任何人都可以帮助我提供一个推理脚本,该脚本可以输入图像并以 json 格式输出预测。我需要一个辅助函数,它可以帮助我获得下面提到的格式的预测。

像这样的东西-

{
  "version": "3.5.0",
  "flags": {},
  "shapes": [
    {
      "label": "plate",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          415,
          235
        ],
        
        [
          416,
          714
        ],
        [
          355,
          597
        ],
        [
          338,
          464
        ],
        [
          357,
          357
        ]
      ],
      "shape_type": "polygon"
    },
    {
      "label": "rice",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          633,
          314
        ],
        [
          651,
          289
        ],
        [
          639,
          279
        ],
        [
          651,
          269
        ],
        
        [
          693,
          565
        ],
        [
          678,
          539
        ],
        [
          667,
          523
        ],
        [
          657,
          450
        ],
        [
          651,
          399
        ],
        [
          637,
          362
        ]
      ],
      "shape_type": "polygon"
    },
    {
      "label": "vegetable",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          687,
          592
        ],
        
        [
          730,
          605
        ],
        [
          718,
          622
        ],
        [
          705,
          629
        ],
        [
          697,
          625
        ]
      ],
      "shape_type": "polygon"
    },
    {
      "label": "chicken",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          433,
          366
        ],
        [
          452,
          340
        ],
        [
          478,
          330
        ],
        [
          507,
          348
        ],
        [
          523,
          370
        ],
        [
          530,
          396
        ],
        [
          539,
          398
        ],
        [
          540,
          379
        ],
        [
          531,
          356
        ],
        [
          530,
          336
        ],
        [
          561,
          328
        ],
        [
          600,
          323
        ],
        [
          626,
          319
        ],
        [
          453,
          407
        ],
        [
          446,
          386
        ]
      ],
      "shape_type": "polygon"
    }
  ],
  "lineColor": [
    0,
    255,
    0,
    128
  ],
  "fillColor": [
    255,
    0,
    0,
    128
  ],
  "imagePath": "test.jpg",
  "imageData": "/9j/4AAQSkZJRgABAQAAAQABAAD

标签: tensorflowdeep-learningcomputer-visionartificial-intelligenceimage-segmentation

解决方案


推荐阅读