Update doclayout_yolo/nn/modules/g2l_crm.py
Browse files
doclayout_yolo/nn/modules/g2l_crm.py
CHANGED
|
@@ -32,9 +32,17 @@ class DilatedBlock(nn.Module):
|
|
| 32 |
self.dcv = Conv(c, c, k=self.k, s=1)
|
| 33 |
|
| 34 |
def dilated_conv(self, x, dilation):
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
def forward(self, x):
|
| 40 |
"""'forward()' applies the YOLO FPN to input data."""
|
|
|
|
| 32 |
self.dcv = Conv(c, c, k=self.k, s=1)
|
| 33 |
|
| 34 |
def dilated_conv(self, x, dilation):
|
| 35 |
+
act = self.dcv.act
|
| 36 |
+
bn = getattr(self.dcv, 'bn', None) # Get bn if it exists, else None
|
| 37 |
+
weight = self.dcv.conv.weight
|
| 38 |
+
padding = dilation * (self.k//2)
|
| 39 |
+
|
| 40 |
+
out = F.conv2d(x, weight, stride=1, padding=padding, dilation=dilation)
|
| 41 |
+
if bn is not None:
|
| 42 |
+
out = bn(out)
|
| 43 |
+
out = act(out)
|
| 44 |
+
return out
|
| 45 |
+
|
| 46 |
|
| 47 |
def forward(self, x):
|
| 48 |
"""'forward()' applies the YOLO FPN to input data."""
|