Shortcuts

mmedit.models.editors.stylegan2.ada.upfirdn2d

Module Contents

Functions

_parse_scaling(scaling)

_parse_padding(padding)

_get_filter_size(f)

upsample2d(x, f[, up, padding, flip_filter, gain, impl])

Upsample a batch of 2D images using the given 2D FIR filter.

setup_filter(f[, device, normalize, flip_filter, ...])

Convenience function to setup 2D FIR filter for upfirdn2d().

downsample2d(x, f[, down, padding, flip_filter, gain, ...])

Downsample a batch of 2D images using the given 2D FIR filter.

mmedit.models.editors.stylegan2.ada.upfirdn2d._parse_scaling(scaling)[source]
mmedit.models.editors.stylegan2.ada.upfirdn2d._parse_padding(padding)[source]
mmedit.models.editors.stylegan2.ada.upfirdn2d._get_filter_size(f)[source]
mmedit.models.editors.stylegan2.ada.upfirdn2d.upsample2d(x, f, up=2, padding=0, flip_filter=False, gain=1, impl='cuda')[source]

Upsample a batch of 2D images using the given 2D FIR filter. By default, the result is padded so that its shape is a multiple of the input. User-specified padding is applied on top of that, with negative values indicating cropping. Pixels outside the image are assumed to be zero. :param x: Float32/float64/float16 input tensor of the shape

[batch_size, num_channels, in_height, in_width].

Parameters
  • f – Float32 FIR filter of the shape [filter_height, filter_width] (non-separable), [filter_taps] (separable), or None (identity).

  • up – Integer upsampling factor. Can be a single int or a list/tuple [x, y] (default: 1).

  • padding – Padding with respect to the output. Can be a single number or a list/tuple [x, y] or [x_before, x_after, y_before, y_after] (default: 0).

  • flip_filter – False = convolution, True = correlation (default: False).

  • gain – Overall scaling factor for signal magnitude (default: 1).

  • impl – Implementation to use. Can be ‘ref’ or ‘cuda’ (default: ‘cuda’).

Returns

Tensor of the shape [batch_size, num_channels, out_height, out_width]

mmedit.models.editors.stylegan2.ada.upfirdn2d.setup_filter(f, device=torch.device('cpu'), normalize=True, flip_filter=False, gain=1, separable=None)[source]

Convenience function to setup 2D FIR filter for upfirdn2d(). :param f: Torch tensor, numpy array, or python list of the shape

[filter_height, filter_width] (non-separable), [filter_taps] (separable), [] (impulse), or None (identity).

Parameters
  • device – Result device (default: cpu).

  • normalize – Normalize the filter so that it retains the magnitude for constant input signal (DC)? (default: True).

  • flip_filter – Flip the filter? (default: False).

  • gain – Overall scaling factor for signal magnitude (default: 1).

  • separable – Return a separable filter? (default: select automatically)

Returns

Float32 tensor of the shape [filter_height, filter_width] (non-separable) or [filter_taps] (separable).

mmedit.models.editors.stylegan2.ada.upfirdn2d.downsample2d(x, f, down=2, padding=0, flip_filter=False, gain=1, impl='cuda')[source]

Downsample a batch of 2D images using the given 2D FIR filter. By default, the result is padded so that its shape is a fraction of the input. User-specified padding is applied on top of that, with negative values indicating cropping. Pixels outside the image are assumed to be zero. :param x: Float32/float64/float16 input tensor of the shape

[batch_size, num_channels, in_height, in_width].

Parameters
  • f – Float32 FIR filter of the shape [filter_height, filter_width] (non-separable), [filter_taps] (separable), or None (identity).

  • down – Integer downsampling factor. Can be a single int or a list/tuple [x, y] (default: 1).

  • padding – Padding with respect to the input. Can be a single number or a list/tuple [x, y] or [x_before, x_after, y_before, y_after] (default: 0).

  • flip_filter – False = convolution, True = correlation (default: False).

  • gain – Overall scaling factor for signal magnitude (default: 1).

  • impl – Implementation to use. Can be ‘ref’ or ‘cuda’ (default: ‘cuda’).

Returns

Tensor of the shape [batch_size, num_channels, out_height, out_width]

Read the Docs v: latest
Versions
master
latest
stable
zyh-re-docs
zyh-doc-notfound-extend
zyh-api-rendering
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.