提交 85bf5356 编写于 作者: keineahnung2345's avatar keineahnung2345 提交者: Waleed

Bug fix: inspect_balloon_model.ipynb

Fix bugs of not showing boxes in 1.b RPN Predictions.
TF 1.9 introduces "ROI/rpn_non_max_suppression/NonMaxSuppressionV3:0", so the original code can't work.
上级 5bd10d73
......@@ -493,10 +493,12 @@
"# Run RPN sub-graph\n",
"pillar = model.keras_model.get_layer(\"ROI\").output # node to start searching from\n",
"\n",
"# TF 1.4 introduces a new version of NMS. Search for both names to support TF 1.3 and 1.4\n",
"# TF 1.4 and 1.9 introduces new versions of NMS. Search for all names to support TF 1.3~1.10\n",
"nms_node = model.ancestor(pillar, \"ROI/rpn_non_max_suppression:0\")\n",
"if nms_node is None:\n",
" nms_node = model.ancestor(pillar, \"ROI/rpn_non_max_suppression/NonMaxSuppressionV2:0\")\n",
"if nms_node is None: #TF 1.9-1.10\n",
" nms_node = model.ancestor(pillar, \"ROI/rpn_non_max_suppression/NonMaxSuppressionV3:0\")\n",
"\n",
"rpn = model.run_graph([image], [\n",
" (\"rpn_class\", model.keras_model.get_layer(\"rpn_class\").output),\n",
......@@ -553,9 +555,12 @@
"# Show top anchors with refinement. Then with clipping to image boundaries\n",
"limit = 50\n",
"ax = get_ax(1, 2)\n",
"visualize.draw_boxes(image, boxes=rpn[\"pre_nms_anchors\"][0, :limit], \n",
" refined_boxes=rpn[\"refined_anchors\"][0, :limit], ax=ax[0])\n",
"visualize.draw_boxes(image, refined_boxes=rpn[\"refined_anchors_clipped\"][0, :limit], ax=ax[1])"
"pre_nms_anchors = utils.denorm_boxes(rpn[\"pre_nms_anchors\"][0], image.shape[:2])\n",
"refined_anchors = utils.denorm_boxes(rpn[\"refined_anchors\"][0], image.shape[:2])\n",
"refined_anchors_clipped = utils.denorm_boxes(rpn[\"refined_anchors_clipped\"][0], image.shape[:2])\n",
"visualize.draw_boxes(image, boxes=pre_nms_anchors[:limit],\n",
" refined_boxes=refined_anchors[:limit], ax=ax[0])\n",
"visualize.draw_boxes(image, refined_boxes=refined_anchors_clipped[:limit], ax=ax[1])"
]
},
{
......@@ -580,7 +585,7 @@
"# Show refined anchors after non-max suppression\n",
"limit = 50\n",
"ixs = rpn[\"post_nms_anchor_ix\"][:limit]\n",
"visualize.draw_boxes(image, refined_boxes=rpn[\"refined_anchors_clipped\"][0, ixs], ax=get_ax())"
"visualize.draw_boxes(image, refined_boxes=refined_anchors_clipped[ixs], ax=get_ax())"
]
},
{
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册