tensorflow - 如何为 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
解决方案
推荐阅读
- sql - 如何组合结果表中的 2 列?
- sql - 当互联网应用程序的输入是 SQL 语句的一部分时,会有哪些安全问题?
- mysql - 查询子索引是否有效
- python - 无法使用请求从网站上抓取不同公司的链接
- google-apps-script - 如何使用 onEdit 触发器获取多个单元格范围的所有旧值
- javascript - 在两条路由之间调用 post 请求方法
- python - 运行时控制 TensorFlow 模块
- struct - Coldfusion Structinsert 正在覆盖原始插入的值
- html - 使用 flexbox 垂直间隔列表和子列表项
- python - 玩python游戏背景音乐不耽误实际游戏