Skip to content

Commit

Permalink
support arbitrary kernel_size
Browse files Browse the repository at this point in the history
fix #10
  • Loading branch information
developer0hye authored Nov 15, 2021
1 parent 4404cce commit 4d958eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ def __init__(self,

super(DeformableConv2d, self).__init__()

assert type(kernel_size) == tuple or type(kernel_size) == int

kernel_size = kernel_size if type(kernel_size) == tuple else (kernel_size, kernel_size)
self.stride = stride if type(stride) == tuple else (stride, stride)
self.padding = padding

self.offset_conv = nn.Conv2d(in_channels,
2 * kernel_size * kernel_size,
2 * kernel_size[0] * kernel_size[1],
kernel_size=kernel_size,
stride=stride,
padding=self.padding,
Expand All @@ -27,7 +30,7 @@ def __init__(self,
nn.init.constant_(self.offset_conv.bias, 0.)

self.modulator_conv = nn.Conv2d(in_channels,
1 * kernel_size * kernel_size,
1 * kernel_size[0] * kernel_size[1],
kernel_size=kernel_size,
stride=stride,
padding=self.padding,
Expand Down Expand Up @@ -59,3 +62,4 @@ def forward(self, x):
stride=self.stride,
)
return x

0 comments on commit 4d958eb

Please sign in to comment.