Commit
·
1fca7a7
1
Parent(s):
e74ccb2
autopad() update in common.py
Browse files- models/common.py +5 -3
models/common.py
CHANGED
@@ -3,9 +3,11 @@
|
|
3 |
from utils.utils import *
|
4 |
|
5 |
|
6 |
-
def autopad(k):
|
7 |
# Pad to 'same'
|
8 |
-
|
|
|
|
|
9 |
|
10 |
|
11 |
def DWConv(c1, c2, k=1, s=1, act=True):
|
@@ -17,7 +19,7 @@ class Conv(nn.Module):
|
|
17 |
# Standard convolution
|
18 |
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups
|
19 |
super(Conv, self).__init__()
|
20 |
-
self.conv = nn.Conv2d(c1, c2, k, s,
|
21 |
self.bn = nn.BatchNorm2d(c2)
|
22 |
self.act = nn.LeakyReLU(0.1, inplace=True) if act else nn.Identity()
|
23 |
|
|
|
3 |
from utils.utils import *
|
4 |
|
5 |
|
6 |
+
def autopad(k, p=None): # kernel, padding
|
7 |
# Pad to 'same'
|
8 |
+
if p is None:
|
9 |
+
p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # auto-pad
|
10 |
+
return p
|
11 |
|
12 |
|
13 |
def DWConv(c1, c2, k=1, s=1, act=True):
|
|
|
19 |
# Standard convolution
|
20 |
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups
|
21 |
super(Conv, self).__init__()
|
22 |
+
self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)
|
23 |
self.bn = nn.BatchNorm2d(c2)
|
24 |
self.act = nn.LeakyReLU(0.1, inplace=True) if act else nn.Identity()
|
25 |
|