Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TopFormer implementation differs from original reference implementation #231

Open
dominikandreas opened this issue Feb 22, 2023 · 0 comments

Comments

@dominikandreas
Copy link

dominikandreas commented Feb 22, 2023

sig_act is computed differently from the original implementation. Complare

global_act = self.global_act(x_global)
global_act = self.act(global_act)
global_act = nn.functional.interpolate(
global_act, size=(H, W), mode='bilinear', align_corners=False)
sigmoid_act = F.interpolate(self.act(global_act), size=(H, W), mode='bilinear', align_corners=False)

with

https://github.com/hustvl/TopFormer/blob/2dc253c49ef78742ca6b44e550c5fea63a274288/mmseg/models/backbones/topformer.py#L328

I assume this is not intentional. The fix is straightforward:

    def forward(self, x_local, x_global):
        '''
        x_g: global features
        x_l: local features
        '''
        B, C, H, W = x_local.shape
        local_feat = self.local_embedding(x_local)
        
        global_act = self.global_act(x_global)
        sig_act = F.interpolate(self.act(global_act), size=(H, W), mode='bilinear', align_corners=False)
        
        global_feat = self.global_embedding(x_global)
        global_feat = F.interpolate(global_feat, size=(H, W), mode='bilinear', align_corners=False)
        
        out = local_feat * sig_act + global_feat
        return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant