-
Notifications
You must be signed in to change notification settings - Fork 304
Conversation
Args: | ||
x (~chainer.Variable): Input variable. The shape is expected to be | ||
4 dimentional: (n: batch, c: channel, h, height, w: width). | ||
rois (~chainer.Variable): Input roi variable. The shape is expected to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is not necessary to make the API of this function to follow chainer.functions.roi_pooling_2d
.
Rather, it would be better to follow the preferred interface of ChainerCV.
Can you change the second input to rois
and roi_indices
as defined here? (bbox
is yx
order)
rois (array): A bounding box array containing coordinates of
proposal boxes. This is a concatenation of bounding box
arrays from multiple images in the batch.
Its shape is :math:`(R', 4)`. Given :math:`R_i` proposed
RoIs from the :math:`i` th image,
:math:`R' = \\sum _{i=1} ^ N R_i`.
roi_indices (array): An array containing indices of images to
which bounding boxes correspond to. Its shape is :math:`(R',)`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require some change to kernels.
def test_backward_gpu(self): | ||
self.check_backward(cuda.to_gpu(self.x), cuda.to_gpu(self.rois), | ||
cuda.to_gpu(self.gy)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a test to check that CPU and GPU outputs are the same?
"""Position Sensitive Region of Interest (ROI) pooling function. | ||
|
||
This function computes position sensitive average of input spatial patch | ||
with the given region of interest. Each ROI are splitted into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
region of interest --> region of interests
Each ROI are --> Each ROI is
This function computes position sensitive average of input spatial patch | ||
with the given region of interest. Each ROI are splitted into | ||
:math:`(group\_size, group\_size)` regions, and position sensitive values | ||
in each region is inferenced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infrenced --> computed
|
||
bottom_data, bottom_rois = inputs | ||
channels, height, width = bottom_data.shape[1:] | ||
n_rois = bottom_rois.shape[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you follow ChainerCV's naming convention? (n_{Singular}
instead of n_{Plural}
)
n_rois
--> n_roi
roi_width = max(xmax - xmin, 0.1) | ||
roi_height = max(ymax - ymin, 0.1) | ||
|
||
strided = 1. * channels / self.outd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove 1.
and add from __future__ import division
?
roi_width = max(xmax - xmin, 0.1) | ||
roi_height = max(ymax - ymin, 0.1) | ||
|
||
strideh = 1. * roi_height / self.outh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
for i_roi in six.moves.range(n_rois): | ||
idx, xmin, ymin, xmax, ymax = bottom_rois[i_roi] | ||
idx = int(idx) | ||
xmin = round(xmin * self.spatial_scale) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables are defined in xy, wh
and yx, hw
orders.
This is inconsistent. Could you reorder them to yx, hw
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it be different from roi_pooling_2d
in chainer
master branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
#545 (comment)
@@ -0,0 +1,331 @@ | |||
# Cuda Kernel Original work by Haozhi Qi (@Oh233) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention license
@yuyu2172 I'm sorry that I rebase the commits again. |
aa2c88b
to
e63e5e9
Compare
|
||
@attr.gpu | ||
@condition.retry(3) | ||
def test_consistency_with_gpu(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check that calculation output of GPU and CPU are same in this test.
595e70e
to
0d75610
Compare
x_min = round(x_min * self.spatial_scale) | ||
y_max = round(y_max * self.spatial_scale) | ||
x_max = round(x_max * self.spatial_scale) | ||
roi_width = max(x_max - x_min, 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order of the two lines are opposite.
roi_height = max(y_max - y_min, 0.1)
roi_width = max(x_max - x_min, 0.1)
'float32 top_data', | ||
''' | ||
// pos in output filter | ||
int pw = i % pooled_width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
round(bottom_rois[n * 4 + 3])) * spatial_scale; | ||
|
||
// Force too small ROIs to be 1x1 | ||
float roi_width = max(roi_end_w - roi_start_w, 0.1); // avoid 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
bool is_empty = (hend <= hstart) || (wend <= wstart); | ||
|
||
// Compute c at bottom | ||
int gw = floor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
static_cast<float>(pw) * group_size / pooled_width); | ||
int gh = floor( | ||
static_cast<float>(ph) * group_size / pooled_height); | ||
gw = min(max(gw, 0), group_size - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
static_cast<float>(pw) * bin_size_w + roi_start_w); | ||
int hstart = floor( | ||
static_cast<float>(ph) * bin_size_h + roi_start_h); | ||
int wend = ceil( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
static_cast<float>(ph + 1.0) * bin_size_h + roi_start_h); | ||
|
||
// Add roi offsets and clip to input boundaries | ||
wstart = min(max(wstart, 0), width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
// Add roi offsets and clip to input boundaries | ||
wstart = min(max(wstart, 0), width); | ||
hstart = min(max(hstart, 0), height); | ||
wend = min(max(wend, 0), width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
bool is_empty = (hend <= hstart) || (wend <= wstart); | ||
|
||
// Compute c at bottom | ||
int gw = floor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
static_cast<float>(pw) * group_size / pooled_width); | ||
int gh = floor( | ||
static_cast<float>(ph) * group_size / pooled_height); | ||
gw = min(max(gw, 0), group_size - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Related to #538
psroi_pooling_2d
psroi_pooling_2d
psroi_pooling_2d
CPU
andGPU
output is same.