Adieee5 commited on
Commit
07a6b59
·
verified ·
1 Parent(s): d6fb134

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
- padding = dilation * (self.k // 2)
36
- # Use conv2d with adjusted dilation and pass through full Conv module (includes act/bn)
37
- return self.dcv(F.pad(x, (padding, padding, padding, padding), mode='constant', value=0), dilation=dilation)
 
 
 
 
 
 
 
 
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."""