Commit eb4d3352 authored by zimenglan's avatar zimenglan Committed by Francisco Massa

rectify the 'padding' for 'DFConv2d' (#717)

* make pixel indexes 0-based for bounding box in pascal voc dataset

* replacing all instances of torch.distributed.deprecated with torch.distributed

* replacing all instances of torch.distributed.deprecated with torch.distributed

* add GroupNorm

* add GroupNorm -- sort out yaml files

* use torch.nn.GroupNorm instead, replace 'use_gn' with 'conv_block' and use 'BaseStem'&'Bottleneck' to simply codes

* modification on 'group_norm' and 'conv_with_kaiming_uniform' function

* modification on yaml files in configs/gn_baselines/ and reduce the amount of indentation and code duplication

* use 'kaiming_uniform' to initialize resnet, disable gn after fc layer, and add dilation into ResNetHead

* agnostic-regression for bbox

* please set 'STRIDE_IN_1X1' to be 'False' when backbone use GN

* add README.md for GN

* add dcn from mmdetection

* add documentation for finetuning cityscapes

* add documentation for finetuning cityscapes

* add documentation for finetuning cityscapes

* add 'once_differentiable' for dcn and modify 'configs/cityscapes/README.md'

* rectify the 'padding' for 'DFConv2d'
parent d44c3fd8
......@@ -127,9 +127,18 @@ class DFConv2d(nn.Module):
):
super(DFConv2d, self).__init__()
if isinstance(kernel_size, (list, tuple)):
assert isinstance(stride, (list, tuple))
assert isinstance(dilation, (list, tuple))
assert len(kernel_size) == 2
assert len(stride) == 2
assert len(dilation) == 2
padding = (
dilation[0] * (kernel_size[0] - 1) // 2,
dilation[1] * (kernel_size[1] - 1) // 2
)
offset_base_channels = kernel_size[0] * kernel_size[1]
else:
padding = dilation * (kernel_size - 1) // 2
offset_base_channels = kernel_size * kernel_size
if with_modulated_dcn:
from maskrcnn_benchmark.layers import ModulatedDeformConv
......@@ -143,8 +152,8 @@ class DFConv2d(nn.Module):
in_channels,
deformable_groups * offset_channels,
kernel_size=kernel_size,
stride= stride,
padding= dilation,
stride=stride,
padding=padding,
groups=1,
dilation=dilation
)
......@@ -155,8 +164,8 @@ class DFConv2d(nn.Module):
in_channels,
out_channels,
kernel_size=kernel_size,
stride= stride,
padding=dilation,
stride=stride,
padding=padding,
dilation=dilation,
groups=groups,
deformable_groups=deformable_groups,
......@@ -165,7 +174,7 @@ class DFConv2d(nn.Module):
self.with_modulated_dcn = with_modulated_dcn
self.kernel_size = kernel_size
self.stride = stride
self.padding = dilation
self.padding = padding
self.dilation = dilation
def forward(self, x):
......
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