basicsr/models/archs/hifacegan_arch.py
def mixed_guidance_forward(self, input, seg=None, n=0, mode='progressive'):
        '''
            A helper class for subspace visualization.
            Input and seg are different images
            For the first n levels (including encoder)
            we use input, for the rest we use seg.

            If mode = 'progressive', the output's like: AAABBB
            If mode = 'one_plug', the output's like:    AAABAA
            If mode = 'one_ablate', the output's like:  BBBABB
        '''

        if seg is None:
            return self.forward(input)

        if self.opt.is_test:
            phase = len(self.to_rgbs)
        else:
            phase = self.opt.train_phase + 1

        if mode == 'progressive':
            n = max(min(n, 4 + phase), 0)
            guide_list = [input] * n + [seg] * (4 + phase - n)
        elif mode == 'one_plug':
            n = max(min(n, 4 + phase - 1), 0)
            guide_list = [seg] * (4 + phase)
            guide_list[n] = input
        elif mode == 'one_ablate':
            if n > 3 + phase:
                return self.forward(input)
            guide_list = [input] * (4 + phase)
            guide_list[n] = seg

        x = self.encode(guide_list[0])
        x = self.head_0(x, guide_list[1])

        x = self.up(x)
        x = self.G_middle_0(x, guide_list[2])
        x = self.G_middle_1(x, guide_list[3])

        for i in range(phase):
            x = self.up(x)
            x = self.ups[i](x, guide_list[4 + i])

        x = self.to_rgbs[phase - 1](F.leaky_relu(x, 2e-1))
        x = torch.tanh(x)

        return x

            A helper class for subspace visualization.
            Input and seg are different images
            For the first n levels (including encoder)
            we use input, for the rest we use seg.

            If mode = 'progressive', the output's like: AAABBB
            If mode = 'one_plug', the output's like:    AAABAA
            If mode = 'one_ablate', the output's like:  BBBABB
        
A helper class for subspace visualization.
Input and seg are different images
For the first n levels (including encoder)
we use input, for the rest we use seg.


A helper class for subspace visualization . Input and seg are different images For the first n levels ( including encoder ) we use input for the rest we use seg .
def mixed_guidance_forward(self, input, seg=None, n=0, mode='progressive'):
        if seg is None:
            return self.forward(input)
        if self.opt.is_test:
            phase = len(self.to_rgbs)
        else:
            phase = self.opt.train_phase + 1
        if mode == 'progressive':
            n = max(min(n, 4 + phase), 0)
            guide_list = [input] * n + [seg] * (4 + phase - n)
        elif mode == 'one_plug':
            n = max(min(n, 4 + phase - 1), 0)
            guide_list = [seg] * (4 + phase)
            guide_list[n] = input
        elif mode == 'one_ablate':
            if n > 3 + phase:
                return self.forward(input)
            guide_list = [input] * (4 + phase)
            guide_list[n] = seg
        x = self.encode(guide_list[0])
        x = self.head_0(x, guide_list[1])
        x = self.up(x)
        x = self.G_middle_0(x, guide_list[2])
        x = self.G_middle_1(x, guide_list[3])
        for i in range(phase):
            x = self.up(x)
            x = self.ups[i](x, guide_list[4 + i])
        x = self.to_rgbs[phase - 1](F.leaky_relu(x, 2e-1))
        x = torch.tanh(x)
        return x
def mixed_guidance_forward ( self , input , seg = None , n = 0 , mode = 'progressive' ) : if seg is None : return self . forward ( input ) if self . opt . is_test : phase = len ( self . to_rgbs ) else : phase = self . opt . train_phase + 1 if mode == 'progressive' : n = max ( min ( n , 4 + phase ) , 0 ) guide_list = [ input ] * n + [ seg ] * ( 4 + phase - n ) elif mode == 'one_plug' : n = max ( min ( n , 4 + phase - 1 ) , 0 ) guide_list = [ seg ] * ( 4 + phase ) guide_list [ n ] = input elif mode == 'one_ablate' : if n > 3 + phase : return self . forward ( input ) guide_list = [ input ] * ( 4 + phase ) guide_list [ n ] = seg x = self . encode ( guide_list [ 0 ] ) x = self . head_0 ( x , guide_list [ 1 ] ) x = self . up ( x ) x = self . G_middle_0 ( x , guide_list [ 2 ] ) x = self . G_middle_1 ( x , guide_list [ 3 ] ) for i in range ( phase ) : x = self . up ( x ) x = self . ups [ i ] ( x , guide_list [ 4 + i ] ) x = self . to_rgbs [ phase - 1 ] ( F . leaky_relu ( x , 2e-1 ) ) x = torch . tanh ( x ) return x
A helper class for subspace visualization.
A helper class for subspace visualization .
'''
            A helper class for subspace visualization.
            Input and seg are different images
            For the first n levels (including encoder)
            we use input, for the rest we use seg.

            If mode = 'progressive', the output's like: AAABBB
            If mode = 'one_plug', the output's like:    AAABAA
            If mode = 'one_ablate', the output's like:  BBBABB
        '''
self
input
seg
n
mode