ooooverflow / BiSeNet

BiSeNet based on pytorch
394 stars 77 forks source link

This Code only supports pytorch==0.4.1 #9

Closed CPFLAME closed 5 years ago

CPFLAME commented 5 years ago

Fisrt I met the same error with https://github.com/ooooverflow/BiSeNet/issues/1 using pytorch==0.4.0, and I met other error using pytorch==1.0.0 When I change the version into 0.4.1, it solved. But when I start training, it can work well with resnet101. When I change the build_contextpath into "resnet18", I met the same error with https://github.com/ooooverflow/BiSeNet/issues/3

seanXYZ commented 5 years ago

If you wanna use resnet 18, make such modifications like below:

  1. class FeatureFusionModule(torch.nn.Module): def init(self, num_classes): super().init()

    self.in_channels = input_1.channels + input_2.channels

    #self.in_channels = 3328  # 3328 = 256(from context path) + 1024(from spatial path) + 2048(from spatial path)
    self.in_channels = 1024  # 1024 = 256(from context path) + 256(from spatial path) + 512(from spatial path)
  2. # build attention refinement module  for resnet 101
    #self.attention_refinement_module1 = AttentionRefinementModule(1024, 1024)
    #self.attention_refinement_module2 = AttentionRefinementModule(2048, 2048)
    
    # build attention refinement module  for resnet 18
    self.attention_refinement_module1 = AttentionRefinementModule(256, 256)
    self.attention_refinement_module2 = AttentionRefinementModule(512, 512)
  3. # supervision block
    # self.supervision1 = nn.Conv2d(in_channels=1024, out_channels=num_classes, kernel_size=1)
    # self.supervision2 = nn.Conv2d(in_channels=2048, out_channels=num_classes, kernel_size=1)
    
    self.supervision1 = nn.Conv2d(in_channels=256, out_channels=num_classes, kernel_size=1)
    self.supervision2 = nn.Conv2d(in_channels=512, out_channels=num_classes, kernel_size=1)
seanXYZ commented 5 years ago

Please make a try and close this issue!