Skip to content

Commit

Permalink
ss (#1)
Browse files Browse the repository at this point in the history
* Fix visualize activations (matterport#1211)

Fix visualize activations (Squashed 4 commits by @keineahnung2345)

# Get activations of a few sample layers
activations = model.run_graph([image], [
    ("input_image",        model.keras_model.get_layer("input_image").output)
])
leads to the error:
InvalidArgumentError: input_image:0 is both fed and fetched.

Revise the code according to https://stackoverflow.com/questions/39307108/placeholder-20-is-both-fed-and-fetched

* Fix typo in config.py

* Fix typo in rpn_class_loss_graph

Fix matterport#870

* Reversed order (1) and (2) in installation

Reference to matterport#1255

* remove unused code (matterport#1227)

Remove unused code
  • Loading branch information
luccauchon authored Feb 4, 2019
1 parent a0a2aa0 commit 61c4d3f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ If you use Docker, the code has been verified to work on


## Installation
1. Install dependencies
1. Clone this repository
2. Install dependencies
```bash
pip3 install -r requirements.txt
```
2. Clone this repository
3. Run setup from the repository root directory
```bash
python3 setup.py install
Expand Down
2 changes: 1 addition & 1 deletion mrcnn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Config(object):
# Minimum scaling ratio. Checked after MIN_IMAGE_DIM and can force further
# up scaling. For example, if set to 2 then images are scaled up to double
# the width and height, or more, even if MIN_IMAGE_DIM doesn't require it.
# Howver, in 'square' mode, it can be overruled by IMAGE_MAX_DIM.
# However, in 'square' mode, it can be overruled by IMAGE_MAX_DIM.
IMAGE_MIN_SCALE = 0
# Number of color channels per image. RGB = 3, grayscale = 1, RGB-D = 4
# Changing this requires other changes in the code. See the WIKI for more
Expand Down
3 changes: 1 addition & 2 deletions mrcnn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ def detection_targets_graph(proposals, gt_class_ids, gt_boxes, gt_masks, config)
crowd_ix = tf.where(gt_class_ids < 0)[:, 0]
non_crowd_ix = tf.where(gt_class_ids > 0)[:, 0]
crowd_boxes = tf.gather(gt_boxes, crowd_ix)
crowd_masks = tf.gather(gt_masks, crowd_ix, axis=2)
gt_class_ids = tf.gather(gt_class_ids, non_crowd_ix)
gt_boxes = tf.gather(gt_boxes, non_crowd_ix)
gt_masks = tf.gather(gt_masks, non_crowd_ix, axis=2)
Expand Down Expand Up @@ -1025,7 +1024,7 @@ def rpn_class_loss_graph(rpn_match, rpn_class_logits):
rpn_match: [batch, anchors, 1]. Anchor match type. 1=positive,
-1=negative, 0=neutral anchor.
rpn_class_logits: [batch, anchors, 2]. RPN classifier logits for FG/BG.
rpn_class_logits: [batch, anchors, 2]. RPN classifier logits for BG/FG.
"""
# Squeeze last dim to simplify
rpn_match = tf.squeeze(rpn_match, -1)
Expand Down
2 changes: 0 additions & 2 deletions mrcnn/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def display_instances(image, boxes, masks, class_ids, class_names,
class_id = class_ids[i]
score = scores[i] if scores is not None else None
label = class_names[class_id]
x = random.randint(x1, (x1 + x2) // 2)
caption = "{} {:.3f}".format(label, score) if score else label
else:
caption = captions[i]
Expand Down Expand Up @@ -436,7 +435,6 @@ def draw_boxes(image, boxes=None, refined_boxes=None,
# If there are refined boxes, display captions on them
if refined_boxes is not None:
y1, x1, y2, x2 = ry1, rx1, ry2, rx2
x = random.randint(x1, (x1 + x2) // 2)
ax.text(x1, y1, caption, size=11, verticalalignment='top',
color='w', backgroundcolor="none",
bbox={'facecolor': color, 'alpha': 0.5,
Expand Down
2 changes: 1 addition & 1 deletion samples/balloon/inspect_balloon_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@
"source": [
"# Get activations of a few sample layers\n",
"activations = model.run_graph([image], [\n",
" (\"input_image\", model.keras_model.get_layer(\"input_image\").output),\n",
" (\"input_image\", tf.identity(model.keras_model.get_layer(\"input_image\").output)),\n",
" (\"res2c_out\", model.keras_model.get_layer(\"res2c_out\").output),\n",
" (\"res3c_out\", model.keras_model.get_layer(\"res3c_out\").output),\n",
" (\"res4w_out\", model.keras_model.get_layer(\"res4w_out\").output), # for resnet100\n",
Expand Down
2 changes: 1 addition & 1 deletion samples/coco/inspect_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@
"source": [
"# Get activations of a few sample layers\n",
"activations = model.run_graph([image], [\n",
" (\"input_image\", model.keras_model.get_layer(\"input_image\").output),\n",
" (\"input_image\", tf.identity(model.keras_model.get_layer(\"input_image\").output)),\n",
" (\"res4w_out\", model.keras_model.get_layer(\"res4w_out\").output), # for resnet100\n",
" (\"rpn_bbox\", model.keras_model.get_layer(\"rpn_bbox\").output),\n",
" (\"roi\", model.keras_model.get_layer(\"ROI\").output),\n",
Expand Down
2 changes: 1 addition & 1 deletion samples/nucleus/inspect_nucleus_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@
"source": [
"# Get activations of a few sample layers\n",
"activations = model.run_graph([image], [\n",
" (\"input_image\", model.keras_model.get_layer(\"input_image\").output),\n",
" (\"input_image\", tf.identity(model.keras_model.get_layer(\"input_image\").output)),\n",
" (\"res2c_out\", model.keras_model.get_layer(\"res2c_out\").output),\n",
" (\"res3c_out\", model.keras_model.get_layer(\"res3c_out\").output),\n",
" (\"rpn_bbox\", model.keras_model.get_layer(\"rpn_bbox\").output),\n",
Expand Down

0 comments on commit 61c4d3f

Please sign in to comment.