tensorflow/models · error · ValueError

If `is_flow`, frames should be given in `tf.float32`.

Error message

If `is_flow`, frames should be given in `tf.float32`.

What it means

Error "If `is_flow`, frames should be given in `tf.float32`." thrown in tensorflow/models.

Source

Thrown at official/projects/videoglue/datasets/common/processors.py:336

  `min_resize`. This allows to save compute time.

  Args:
    frames: A tensor of dimension [timesteps, input_h, input_w, channels].
    min_resize: Minimum size of the final image dimensions.
    is_flow: If is flow, will modify the raw values to account for the resize.
      For example, if the flow image is resized by a factor k, we need to
      multiply the flow values by the same factor k since one pixel displacement
      in the resized image corresponds to only 1/k pixel displacement in the
      original image.
    state: A mutable dictionary passed to the stateful functions and might be
      modified in order to keep metadata.

  Returns:
    A tensor of shape [timesteps, output_h, output_w, channels] of same type as
    input, where `min(output_h, output_w)` is `min_resize`.
  """
  if is_flow and frames.dtype != tf.float32:
    raise ValueError('If `is_flow`, frames should be given in `tf.float32`.')
  shape = tf.shape(input=frames)
  input_h = shape[1]
  input_w = shape[2]

  output_h = tf.maximum(min_resize, (input_h * min_resize) // input_w)
  output_w = tf.maximum(min_resize, (input_w * min_resize) // input_h)

  def resize_fn():
    """Bilinear resize function wrapper."""
    frames_resized = tf.image.resize(
        frames, (output_h, output_w), method=tf.image.ResizeMethod.BILINEAR)
    return tf.cast(frames_resized, frames.dtype)

  should_resize = tf.math.logical_or(tf.not_equal(input_w, output_w),
                                     tf.not_equal(input_h, output_h))
  frames = tf.cond(
      pred=should_resize, true_fn=resize_fn, false_fn=lambda: frames)

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/videoglue/datasets/common/processors.py:336 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/5c42c48d1753858b. Report an issue: GitHub.