pyiqa.archs.interpolate_compat_tensorflow

This file is taken from: https://github.com/toshas/torch-fidelity/blob/master/torch_fidelity/interpolate_compat_tensorflow.py

Module Contents

pyiqa.archs.interpolate_compat_tensorflow.interpolate_bilinear_2d_like_tensorflow1x(input, size=None, scale_factor=None, align_corners=None, method='slow')[source]

Down/up samples the input to either the given size or the given scale_factor

Epsilon-exact bilinear interpolation as it is implemented in TensorFlow 1.x: https://github.com/tensorflow/tensorflow/blob/f66daa493e7383052b2b44def2933f61faf196e0/tensorflow/core/kernels/image_resizer_state.h#L41 https://github.com/tensorflow/tensorflow/blob/6795a8c3a3678fb805b6a8ba806af77ddfe61628/tensorflow/core/kernels/resize_bilinear_op.cc#L85 as per proposal: https://github.com/pytorch/pytorch/issues/10604#issuecomment-465783319

Related materials: https://hackernoon.com/how-tensorflows-tf-image-resize-stole-60-days-of-my-life-aba5eb093f35 https://jricheimer.github.io/tensorflow/2019/02/11/resize-confusion/ https://machinethink.net/blog/coreml-upsampling/

Currently only 2D spatial sampling is supported, i.e. expected inputs are 4-D in shape.

The input dimensions are interpreted in the form: mini-batch x channels x height x width.

Parameters:
  • input (Tensor) – the input tensor

  • size (Tuple[int, int]) – output spatial size.

  • scale_factor (float or Tuple[float]) – multiplier for spatial size. Has to match input size if it is a tuple.

  • align_corners (bool, optional) – Same meaning as in TensorFlow 1.x.

  • method (str, optional) – ‘slow’ (1e-4 L_inf error on GPU, bit-exact on CPU, with checkerboard 32x32->299x299), or ‘fast’ (1e-3 L_inf error on GPU and CPU, with checkerboard 32x32->299x299)