Skip to content

Commit 56f76d6

Browse files
committed
add ROI
1 parent 524538b commit 56f76d6

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

tensorlayer/layers.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,6 +3625,48 @@ def __init__(
36253625
self.all_drop = dict(layer.all_drop)
36263626
self.all_layers.extend( [self.outputs] )
36273627

3628+
## Object Detection
3629+
class ROIPoolingLayer(Layer):
3630+
"""
3631+
The :class:`ROIPoolingLayer` class is Region of interest pooling layer.
3632+
3633+
Parameters
3634+
-----------
3635+
layer : a :class:`Layer` instance
3636+
The `Layer` class feeding into this layer, the feature maps on which to perform the pooling operation
3637+
rois : list of regions of interest in the format (feature map index, upper left, bottom right)
3638+
pool_width : int, size of the pooling sections.
3639+
pool_width : int, size of the pooling sections.
3640+
3641+
References
3642+
-----------
3643+
- From `Deepsense-AI <https://github.com/deepsense-ai/roi-pooling>`_ .
3644+
"""
3645+
def __init__(
3646+
self,
3647+
#inputs = None,
3648+
layer = None,
3649+
rois = None,
3650+
pool_height = 2,
3651+
pool_width = 2,
3652+
name = 'roipooling_layer',
3653+
):
3654+
Layer.__init__(self, name=name)
3655+
self.inputs = layer.outputs
3656+
print (" [TL] ROIPoolingLayer %s: (%d, %d)" % (self.name, pool_height, pool_width))
3657+
try:
3658+
from tensorlayer.third_party.roi_pooling.roi_pooling.roi_pooling_ops import roi_pooling
3659+
except Exception as e:
3660+
print(e)
3661+
print("\nHINT: \n1. https://github.com/deepsense-ai/roi-pooling \n2. tensorlayer/third_party/roi_pooling\n")
3662+
self.outputs = roi_pooling(self.inputs, rois, pool_height, pool_width)
3663+
3664+
self.all_layers = list(layer.all_layers)
3665+
self.all_params = list(layer.all_params)
3666+
self.all_drop = dict(layer.all_drop)
3667+
self.all_layers.extend( [self.outputs] )
3668+
3669+
36283670
## TimeDistributedLayer
36293671
class TimeDistributedLayer(Layer):
36303672
"""

tensorlayer/third_party/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit d1ae7e0b702d1f4a1672e793184324379b96ecb0

0 commit comments

Comments
 (0)