sithu31296 / semantic-segmentation

SOTA Semantic Segmentation Models in PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BiSeNetV2 model

uyolo1314 opened this issue · comments

commented

There are some differences between your implementation and others (PaddleSeg, mmsegmentation, BiSeNet)

For example:
Your implementation

class AggregationLayer(nn.Module):
def __init__(self) -> None:
super().__init__()
self.left1 = nn.Sequential(
nn.Conv2d(128, 128, 3, 1, 1, groups=128, bias=False),
nn.BatchNorm2d(128),
nn.Conv2d(128, 128, 1, 1, 0, bias=False)
)
self.left2 = nn.Sequential(
nn.Conv2d(128, 128, 3, 2, 1, bias=False),
nn.BatchNorm2d(128),
nn.AvgPool2d(3, 2, 1, ceil_mode=False)
)
self.right1 = nn.Sequential(
nn.Conv2d(128, 128, 3, 1, 1, bias=False),
nn.BatchNorm2d(128),
nn.Upsample(scale_factor=4),
nn.Sigmoid()
)
self.right2 = nn.Sequential(
nn.Conv2d(128, 128, 3, 1, 1, groups=128, bias=False),
nn.BatchNorm2d(128),
nn.Conv2d(128, 128, 1, 1, 0, bias=False),
nn.Sigmoid()
)
self.up = nn.Upsample(scale_factor=4)
self.conv = ConvModule(128, 128, 3, 1, 1)
def forward(self, x_d, x_s):
x1 = self.left1(x_d)
x2 = self.left2(x_d)
x3 = self.right1(x_s)
x4 = self.right2(x_s)
left = x1 * x3
right = x2 * x4
right = self.up(right)
out = left + right
return self.conv(out)

Others
https://github.com/PaddlePaddle/PaddleSeg/blob/13aac35b31b147d2dd9976821ade13dabebff685/paddleseg/models/bisenet.py#L253-L302

https://github.com/CoinCheung/BiSeNet/blob/f2b901599752ce50656d2e50908acecd06f7eb47/lib/models/bisenetv2.py#L224

AggregationLayer only uses one resize op, others have two resize ops