CharlesShang / FastMaskRCNN

Mask RCNN in TensorFlow
Apache License 2.0
3.1k stars 1.1k forks source link

What is 'assigned_rois' in network.py? #119

Closed hgfm closed 7 years ago

hgfm commented 7 years ago

In pyramid_network.py,

rois, scores, batch_inds, mask_rois, mask_scores, mask_batch_inds = \
                sample_rpn_outputs_with_gt(rois, rpn_probs[:, 1], gt_boxes, is_training=is_training)

[assigned_rois, assigned_batch_inds, assigned_layer_inds] = \
                assign_boxes(rois, [rois, batch_inds], [2, 3, 4, 5])

splitted_rois = assigned_rois[i-2]
batch_inds = assigned_batch_inds[i-2]
cropped, boxes_in_crop = ROIAlign_(pyramid[p], splitted_rois, batch_inds, ih, iw, stride=2**i,
                               pooled_height=14, pooled_width=14)

First, what's the function of 'sample_rpn_outputs_with_gt'? I also find 'sample_rpn_outputs' which is easy to understand, but I cannot understand 'sample_rpn_outputs_with_gt'.

Second,what's the function of 'assign_boxes'?

Thank you for your help!

souryuu commented 7 years ago

"sample_rpn_outputs_with_gt" is the function for selecting ROIs that match with gt. We need it for selecting which ROIs will be used for training.

"assign_boxes" is the function for assigning a layer index to selected ROIs. We need need this in order to find which pyramid layer each ROI belongs to.

Sharathnasa commented 7 years ago

Hi Souryu,

Thank you for explaining, "what sample_rpn_outputs_with_gt" and "assign_boxes" functions.

Could you please let me know what below mentioned function are doing, so that we can get a clear understanding.

  1. anchor_decoder
  2. ROIAlign_
  3. roi_decoder
  4. gen_all_anchors

Regards, Sharath

On Mon, Jul 31, 2017 at 7:52 AM, souryuu notifications@github.com wrote:

"sample_rpn_outputs_with_gt" is the function for selecting ROIs that match with gt. We need it for selecting which ROIs will be used for training.

"assign_boxes" is the function for assigning a layer index to selected ROIs. We need need this in order to find which pyramid layer each ROI belongs to.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CharlesShang/FastMaskRCNN/issues/119#issuecomment-318951625, or mute the thread https://github.com/notifications/unsubscribe-auth/AHMgszG0EQ7xDbtaZslcuzq68UiWU8Eeks5sTTp2gaJpZM4OmWoB .

-- Regards, Sharath Kumar R

The only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it.” - Steve Jobs (1955 - 2011)

souryuu commented 7 years ago

All these functions were explained in the source code. You can find them in libs/layer/ xxx.py.

1). "anchor_decoder" is used for transforming raw output neurons of RPN network (boxes(h,w,4) and scores(h,w,2) ) and all_anchors to bounding box coordinates (h x w, 4) and probability that an object is inside that bounding box (h x w, 1). I may be wrong about the dimension but you can check them by printing out the value from anchor.py

2). "ROIAlign" is used to crop_and_resize the shared CNN features according to ROIs.

3). "roi_decoder" is similar to "anchor_decoder" but for RCNN network. It transformed raw output of the RCNN network to bounding box by selecting only the coordinates of the class with the highest probability.

4). "gen_all_anchors" is a function to create anchors given a spatial plane (e.g. spatial location from a pyramid network)

hgfm commented 7 years ago

@souryuu thank you ! I have understand the code, and I also find the part about batch_inds, which means the boxes belong to which batch has not finish, I will try to do this : )