tensorflow/models · error · ValueError

crop_type must be one of {list(crop_type_index.keys())}

Error message

crop_type must be one of {list(crop_type_index.keys())}

What it means

Error "crop_type must be one of {list(crop_type_index.keys())}" thrown in tensorflow/models.

Source

Thrown at official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/sam3_inference_utils.py:663

    thumbnail_size: int = 3,
) -> None:
  """Displays detection crops as a grid of labeled thumbnails.

  Args:
      crop_pairs: List of tuples from ``process_detections``, each containing
        ``(detection_index, raw_crop, masked_crop, blended_crop)``.
      state: SAM output dict containing ``'scores'``.
      crop_type: Which crop to display. One of ``'raw'``, ``'masked'``,
        ``'blended'``.
      columns_per_row: Maximum number of thumbnails per row.
      thumbnail_size: Size of each thumbnail in inches.

  Raises:
      ValueError: If ``crop_type`` is not one of the allowed values.
  """
  crop_type_index = {"raw": 1, "masked": 2, "blended": 3}
  if crop_type not in crop_type_index:
    raise ValueError(f"crop_type must be one of {list(crop_type_index.keys())}")

  idx = crop_type_index[crop_type]
  valid_pairs = [pair for pair in crop_pairs if pair[idx] is not None]

  total_crops = len(valid_pairs)
  if total_crops == 0:
    print("No valid crops to display.")
    return

  num_columns = min(total_crops, columns_per_row)
  num_rows = math.ceil(total_crops / num_columns)

  _, axes = plt.subplots(
      num_rows,
      num_columns,
      figsize=(num_columns * thumbnail_size, num_rows * thumbnail_size),
  )

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/sam3_inference_utils.py:663 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/a77907c98e2968cd. Report an issue: GitHub.