Commit
·
e071b8d
1
Parent(s):
b8557f8
update models/common.py for Conv() flexible padding
Browse files- models/common.py +2 -1
models/common.py
CHANGED
@@ -13,7 +13,8 @@ class Conv(nn.Module):
|
|
13 |
# Standard convolution
|
14 |
def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups
|
15 |
super(Conv, self).__init__()
|
16 |
-
|
|
|
17 |
self.bn = nn.BatchNorm2d(c2)
|
18 |
self.act = nn.LeakyReLU(0.1, inplace=True) if act else nn.Identity()
|
19 |
|
|
|
13 |
# Standard convolution
|
14 |
def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups
|
15 |
super(Conv, self).__init__()
|
16 |
+
p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # padding
|
17 |
+
self.conv = nn.Conv2d(c1, c2, k, s, p, groups=g, bias=False)
|
18 |
self.bn = nn.BatchNorm2d(c2)
|
19 |
self.act = nn.LeakyReLU(0.1, inplace=True) if act else nn.Identity()
|
20 |
|