提交 61834b4d 编写于 作者: W Waleed

Apply previous commit to the other notebooks

上级 85bf5356
......@@ -493,7 +493,7 @@
"# Run RPN sub-graph\n",
"pillar = model.keras_model.get_layer(\"ROI\").output # node to start searching from\n",
"\n",
"# TF 1.4 and 1.9 introduces new versions of NMS. Search for all names to support TF 1.3~1.10\n",
"# TF 1.4 and 1.9 introduce 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",
......@@ -566,10 +566,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 introduce 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",
......@@ -626,9 +628,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])"
]
},
{
......@@ -653,7 +658,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())"
]
},
{
......@@ -569,10 +569,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 introduce 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[np.newaxis], [\n",
" (\"rpn_class\", model.keras_model.get_layer(\"rpn_class\").output),\n",
......@@ -629,13 +631,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(\n",
" image, ax=ax[0],\n",
" boxes=utils.denorm_boxes(rpn[\"pre_nms_anchors\"][0, :limit], image.shape[:2]), \n",
" refined_boxes=utils.denorm_boxes(rpn[\"refined_anchors\"][0, :limit], image.shape[:2]))\n",
"visualize.draw_boxes(\n",
" image, ax=ax[1],\n",
" refined_boxes=utils.denorm_boxes(rpn[\"refined_anchors_clipped\"][0, :limit], image.shape[:2]))"
"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])"
]
},
{
......@@ -660,9 +661,7 @@
"# Show refined anchors after non-max suppression\n",
"limit = 50\n",
"ixs = rpn[\"post_nms_anchor_ix\"][:limit]\n",
"visualize.draw_boxes(\n",
" image, ax=get_ax(),\n",
" refined_boxes=utils.denorm_boxes(rpn[\"refined_anchors_clipped\"][0, ixs], image.shape[:2]))"
"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.
先完成此消息的编辑!
想要评论请 注册