tensorflow/models · error · ValueError

field does not exist

Error message

field %s does not exist

What it means

Missing-field guard in BoxList.get_field: the accessor does a plain dict lookup in self.data after has_field(); requesting a field name that was never add_field()-ed (e.g. 'scores' or 'classes' on a bare BoxList) hits this refusal instead of a KeyError.

Solutions

  1. Add the field with add_field before reading it, or check the field name for typos.
  2. Use has_field to guard access to optional fields.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/vision/utils/object_detection/box_list.py:138 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/1c8e412eca347097. Report an issue: GitHub.

Appendix: source

Thrown at official/vision/utils/object_detection/box_list.py:138

  def get_field(self, field):
    """Accesses a box collection and associated fields.

    This function returns specified field with object; if no field is specified,
    it returns the box coordinates.

    Args:
      field: this optional string parameter can be used to specify a related
        field to be accessed.

    Returns:
      a tensor representing the box collection or an associated field.

    Raises:
      ValueError: if invalid field
    """
    if not self.has_field(field):
      raise ValueError('field ' + str(field) + ' does not exist')
    return self.data[field]

  def set_field(self, field, value):
    """Sets the value of a field.

    Updates the field of a box_list with a given value.

    Args:
      field: (string) name of the field to set value.
      value: the value to assign to the field.

    Raises:
      ValueError: if the box_list does not have specified field.
    """
    if not self.has_field(field):
      raise ValueError('field %s does not exist' % field)
    self.data[field] = value

View on GitHub (pinned to e006f5f0d5)