ZHKKKe / MODNet

A Trimap-Free Portrait Matting Solution in Real Time [AAAI 2022]
Apache License 2.0
3.84k stars 636 forks source link

关于e-ASPP #212

Open MangekyoSasuke opened 1 year ago

MangekyoSasuke commented 1 year ago

你好!我想学习e-ASPP是如何写出来的?请问有参考吗?

munibkhanali commented 1 year ago

Hi @MangekyoSasuke Description of eASSP in paper is not specific enough, but i have implemented it as far as i understood it form paper. I will call it LightEfficientASPP, Author of the Modnet(@ZHKKKe ) claim eASSP has 1% of the ASSP parameters and 1% computational cost. but LightEfficientASPP has 1.8 % parameters and computational cost.

it will be so kind of @ZHKKKe if he comments on LightEfficientASPP

class LightEfficientASPP(nn.Module):
    def __init__(self, in_channels, dilation_rates=[6, 12, 18], channel_reduction=4):
        super(LightEfficientASPP, self).__init__()

        out_channels=in_channels // channel_reduction
        # Channel reduction
        self.channel_reduction_conv = Conv2dIBNormRelu(in_channels, in_channels // channel_reduction, kernel_size=1)
        c1_out=out_channels
        c2_out=c1_out//channel_reduction
        c2_out=c2_out//channel_reduction
        # Depth-wise atrous convolutions with point-wise convolutions
        self.conv3x3_1 = nn.Sequential(
            Conv2dIBNormRelu(c1_out, c1_out, kernel_size=3, padding=dilation_rates[0], dilation=dilation_rates[0], groups=c1_out),
            Conv2dIBNormRelu(c1_out, c1_out, kernel_size=1)
        )
        self.conv3x3_2 = nn.Sequential(
            Conv2dIBNormRelu(out_channels, c2_out, kernel_size=3, padding=dilation_rates[1], dilation=dilation_rates[1], groups=c2_out),
            Conv2dIBNormRelu(c2_out, c2_out, kernel_size=1)
        )
        self.conv3x3_3 = nn.Sequential(
            Conv2dIBNormRelu(out_channels, c2_out, kernel_size=3, padding=dilation_rates[2], dilation=dilation_rates[2], groups=c2_out),
            Conv2dIBNormRelu(c2_out, c2_out, kernel_size=1)
        )

        # Recover the number of channels
        self.recover_channels = Conv2dIBNormRelu(c1_out+c2_out+c2_out, in_channels, kernel_size=1)

    def forward(self, x):
        reduced_features = self.channel_reduction_conv(x)
        conv3x3_1 = self.conv3x3_1(reduced_features)
        conv3x3_2 = self.conv3x3_2(reduced_features)
        conv3x3_3 = self.conv3x3_3(reduced_features)
        combined_features = torch.cat([conv3x3_1, conv3x3_2,conv3x3_3], dim=1)
        output = self.recover_channels(combined_features)

        return output

Thank you

MangekyoSasuke commented 1 year ago

Excuse me! I am a student form Shanghai, China. I sincerely respect your work and achievements, and decide to train the MODNet on my computer. May I ask you for the training code? I guarantee that I won’t use it for commercial purposes, and if I have some achievements, I will write your name in the acknowledgement . Oceans of thanks! Tianyu Zhang East China University of Science and Technology

At 2023-09-27 22:47:08, "munibkhanali" @.***> wrote:

Hi @MangekyoSasuke Description eASSP in paper is not specific enough, but i have implemented it as far as i understood it form paper. I will call it LightEfficientASPP, Author of the @.*** ) claim eASSP has 1% of the ASSP parameters and 1% computational cost. but LightEfficientASPP has 1.8 % parameters and computational cost.

it will be so kind of @ZHKKKe if he comments on LightEfficientASPP

class LightEfficientASPP(nn.Module): def init(self, in_channels, dilation_rates=[6, 12, 18], channel_reduction=4): super(LightEfficientASPP, self).init()

    out_channels=in_channels // channel_reduction
    # Channel reduction
    self.channel_reduction_conv = Conv2dIBNormRelu(in_channels, in_channels // channel_reduction, kernel_size=1)
    c1_out=out_channels
    c2_out=c1_out//channel_reduction
    c2_out=c2_out//channel_reduction
    # Depth-wise atrous convolutions with point-wise convolutions
    self.conv3x3_1 = nn.Sequential(
        Conv2dIBNormRelu(c1_out, c1_out, kernel_size=3, padding=dilation_rates[0], dilation=dilation_rates[0], groups=c1_out),
        Conv2dIBNormRelu(c1_out, c1_out, kernel_size=1)
    )
    self.conv3x3_2 = nn.Sequential(
        Conv2dIBNormRelu(out_channels, c2_out, kernel_size=3, padding=dilation_rates[1], dilation=dilation_rates[1], groups=c2_out),
        Conv2dIBNormRelu(c2_out, c2_out, kernel_size=1)
    )
    self.conv3x3_3 = nn.Sequential(
        Conv2dIBNormRelu(out_channels, c2_out, kernel_size=3, padding=dilation_rates[2], dilation=dilation_rates[2], groups=c2_out),
        Conv2dIBNormRelu(c2_out, c2_out, kernel_size=1)
    )

    # Recover the number of channels
    self.recover_channels = Conv2dIBNormRelu(c1_out+c2_out+c2_out, in_channels, kernel_size=1)

def forward(self, x):
    reduced_features = self.channel_reduction_conv(x)
    conv3x3_1 = self.conv3x3_1(reduced_features)
    conv3x3_2 = self.conv3x3_2(reduced_features)
    conv3x3_3 = self.conv3x3_3(reduced_features)
    combined_features = torch.cat([conv3x3_1, conv3x3_2,conv3x3_3], dim=1)
    output = self.recover_channels(combined_features)

    return output

Thank you

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

vodatvan01 commented 6 months ago

How is the performance?

munibkhanali commented 6 months ago

Hi @vodatvan01 , The Performance is pretty comparable.