"dialogctrl/ner/src/utils.py" did not exist on "7d044e4e58b5b479c908c94442a413af36b1a97e"
Unverified Commit b04ad69d authored by pc's avatar pc Committed by GitHub
Browse files

[Feature] Add 6 rotated detection ops in parrots (#1665)

* add active_rotated_filter, convex_iou, min_area_polygons, points_in_polygons, riroi_align_roteted, rotated_feature_align in parrots

* fix lint

* fix lint
parent 86ed509a
...@@ -41,10 +41,16 @@ class RiRoIAlignRotatedFunction(Function): ...@@ -41,10 +41,16 @@ class RiRoIAlignRotatedFunction(Function):
output = features.new_zeros(num_rois, num_channels, out_h, out_w) output = features.new_zeros(num_rois, num_channels, out_h, out_w)
ext_module.riroi_align_rotated_forward(features, rois, output, out_h, ext_module.riroi_align_rotated_forward(
out_w, spatial_scale, features,
num_samples, num_orientations, rois,
clockwise) output,
pooled_height=out_h,
pooled_width=out_w,
spatial_scale=spatial_scale,
num_samples=num_samples,
num_orientations=num_orientations,
clockwise=clockwise)
return output return output
@staticmethod @staticmethod
...@@ -67,8 +73,15 @@ class RiRoIAlignRotatedFunction(Function): ...@@ -67,8 +73,15 @@ class RiRoIAlignRotatedFunction(Function):
grad_input = rois.new_zeros(batch_size, num_channels, feature_h, grad_input = rois.new_zeros(batch_size, num_channels, feature_h,
feature_w) feature_w)
ext_module.riroi_align_rotated_backward( ext_module.riroi_align_rotated_backward(
grad_output.contiguous(), rois, grad_input, out_h, out_w, grad_output.contiguous(),
spatial_scale, num_samples, num_orientations, clockwise) rois,
grad_input,
pooled_height=out_h,
pooled_width=out_w,
spatial_scale=spatial_scale,
num_samples=num_samples,
num_orientations=num_orientations,
clockwise=clockwise)
return grad_input, grad_rois, None, None, None, None, None return grad_input, grad_rois, None, None, None, None, None
......
...@@ -40,8 +40,12 @@ class RotatedFeatureAlignFunction(Function): ...@@ -40,8 +40,12 @@ class RotatedFeatureAlignFunction(Function):
ctx.save_for_backward(best_rbboxes) ctx.save_for_backward(best_rbboxes)
assert points in [1, 5] assert points in [1, 5]
output = torch.zeros_like(features) output = torch.zeros_like(features)
ext_module.rotated_feature_align_forward(features, best_rbboxes, ext_module.rotated_feature_align_forward(
output, spatial_scale, points) features,
best_rbboxes,
output,
spatial_scale=spatial_scale,
points=points)
return output return output
@staticmethod @staticmethod
...@@ -61,9 +65,12 @@ class RotatedFeatureAlignFunction(Function): ...@@ -61,9 +65,12 @@ class RotatedFeatureAlignFunction(Function):
grad_input = None grad_input = None
if ctx.needs_input_grad[0]: if ctx.needs_input_grad[0]:
grad_input = torch.zeros_like(grad_output) grad_input = torch.zeros_like(grad_output)
ext_module.rotated_feature_align_backward(grad_output.contiguous(), ext_module.rotated_feature_align_backward(
best_rbboxes, grad_input, grad_output.contiguous(),
spatial_scale, points) best_rbboxes,
grad_input,
spatial_scale=spatial_scale,
points=points)
return grad_input, None, None, None return grad_input, None, None, None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment