tensorflow/models · error · ValueError

In TRAIN mode, padding/truncation is required.

Error message

In TRAIN mode, padding/truncation is required.

What it means

Error "In TRAIN mode, padding/truncation is required." thrown in tensorflow/models.

Source

Thrown at official/projects/unified_detector/data_loaders/universal_detection_parser.py:134

        operations.
      randaug_prob: (autoaugment parameter) Probabilily of applying each
        distortion operation.
      use_cropping: Bool, whether to use random cropping and resizing in
        training.
      crop_min_scale: The minimum scale of a random crop.
      crop_max_scale: The maximum scale of a random crop. If >1, it means the
        images are downsampled.
      crop_min_aspect: The minimum aspect ratio of a random crop.
      crop_max_aspect: The maximum aspect ratio of a random crop.
      is_shape_defined: Whether to define the static shapes for all features and
        labels. This must be set to True in TPU training as it requires static
        shapes for all tensors.
      use_tpu: Whether the inputs are fed to a TPU device.
      detection_unit: Whether word or line (or else) is regarded as an entity.
        The instance masks will be at word or line level.
    """
    if is_training and max_num_instance < 0:
      raise ValueError('In TRAIN mode, padding/truncation is required.')

    self._is_training = is_training
    self._output_dimension = output_dimension
    self._mask_dimension = (
        mask_dimension if mask_dimension > 0 else output_dimension)
    self._max_num_instance = max_num_instance
    self._decoder = tf_example_decoder.TfExampleDecoder(
        num_additional_channels=3, additional_class_names=['parent'])
    self._use_color_distortion = use_color_distortion
    self._rot90_probability = rot90_probability
    self._randaug_mag = randaug_mag
    self._randaug_std = randaug_std
    self._randaug_layer = randaug_layer
    self._randaug_prob = randaug_prob
    self._use_cropping = use_cropping
    self._crop_min_scale = crop_min_scale
    self._crop_max_scale = crop_max_scale
    self._crop_min_aspect = crop_min_aspect

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/unified_detector/data_loaders/universal_detection_parser.py:134 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/c0a5f4f033d985ad. Report an issue: GitHub.