Skip to content

Commit a9e5fed

Browse files
committed
modify bilinear operation.
1 parent a23ebe5 commit a9e5fed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

deform_conv.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def forward(self, x, offset):
1717
ks = self.kernel_size
1818
N = offset.size(1) // 2
1919

20+
# Change offset's order from [x1, x2, ..., y1, y2, ...] to [x1, y1, x2, y2, ...]
2021
# Codes below are written to make sure same results of MXNet implementation.
2122
# You can remove them, and it won't influence the module's performance.
2223
offsets_index = Variable(torch.cat([torch.arange(0, 2*N, 2), torch.arange(1, 2*N+1, 2)]), requires_grad=False).type_as(x).long()
@@ -74,7 +75,7 @@ def forward(self, x, offset):
7475
def _get_p_n(self, N, dtype):
7576
p_n_x, p_n_y = np.meshgrid(range(-(self.kernel_size-1)//2, (self.kernel_size-1)//2+1),
7677
range(-(self.kernel_size-1)//2, (self.kernel_size-1)//2+1), indexing='ij')
77-
# (2N, 1), order[x1, x2, ..., y1, y2, ...]
78+
# (2N, 1)
7879
p_n = np.concatenate((p_n_x.flatten(), p_n_y.flatten()))
7980
p_n = np.reshape(p_n, (1, 2*N, 1, 1))
8081
p_n = Variable(torch.from_numpy(p_n).type(dtype), requires_grad=False)

0 commit comments

Comments
 (0)