Skip to content

Commit

Permalink
Adds min probability threshold filter to RCNN proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
vierja committed Oct 10, 2017
1 parent c09352c commit 4b8a811
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions luminoth/models/fasterrcnn/base_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ rcnn:
class_nms_threshold: 0.6
# Maximum total detections for an image (sorted by score)
total_max_detections: 300
# Minimum prob to be used as proposed object
min_prob_threshold: 0.5

target:
# Ratio between foreground and background samples in minibatch
Expand Down
1 change: 1 addition & 0 deletions luminoth/models/fasterrcnn/fasterrcnn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def setUp(self):
'class_max_detections': 100,
'class_nms_threshold': 0.6,
'total_max_detections': 300,
'min_prob_threshold': 0.0,
},
'target': {
'foreground_fraction': 0.25,
Expand Down
11 changes: 10 additions & 1 deletion luminoth/models/fasterrcnn/rcnn_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def __init__(self, num_classes, config, name='rcnn_proposal'):
self._class_nms_threshold = config.class_nms_threshold
# Maximum number of detections to return.
self._total_max_detections = config.total_max_detections
# Threshold probability
self._min_prob_threshold = config.min_prob_threshold or 0.0

def _build(self, proposals, bbox_pred, cls_prob, im_shape):
"""
Expand Down Expand Up @@ -75,7 +77,14 @@ def _build(self, proposals, bbox_pred, cls_prob, im_shape):
proposal_label_prob = tf.reduce_max(cls_prob, axis=1)

# We are going to use only the non-background proposals.
proposal_filter = tf.greater_equal(proposal_label, 0)
non_background_filter = tf.greater_equal(proposal_label, 0)
# Filter proposals with less than threshold probability.
min_prob_filter = tf.greater_equal(
proposal_label_prob, self._min_prob_threshold
)
proposal_filter = tf.logical_and(
non_background_filter, min_prob_filter
)

equal_shapes = tf.assert_equal(
tf.shape(proposals)[0], tf.shape(bbox_pred)[0]
Expand Down
1 change: 1 addition & 0 deletions luminoth/models/fasterrcnn/rcnn_proposal_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def setUp(self):
'class_max_detections': 100,
'class_nms_threshold': 0.6,
'total_max_detections': 300,
'min_prob_threshold': 0.0,
})

self._equality_delta = 1e-03
Expand Down
1 change: 1 addition & 0 deletions luminoth/models/fasterrcnn/rcnn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def setUp(self):
'class_max_detections': 100,
'class_nms_threshold': 0.6,
'total_max_detections': 300,
'min_prob_threshold': 0.0,
},
'target': {
'foreground_fraction': 0.25,
Expand Down

0 comments on commit 4b8a811

Please sign in to comment.