Skip to content

Commit

Permalink
Apply previous commit to the other notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
waleedka committed Sep 21, 2018
1 parent 85bf535 commit 61834b4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion samples/balloon/inspect_balloon_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 10 additions & 5 deletions samples/coco/inspect_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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])"
]
},
{
Expand All @@ -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())"
]
},
{
Expand Down
21 changes: 10 additions & 11 deletions samples/nucleus/inspect_nucleus_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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])"
]
},
{
Expand All @@ -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())"
]
},
{
Expand Down

0 comments on commit 61834b4

Please sign in to comment.