{"record":{"id":"a77907c98e2968cd","repo":"tensorflow/models","slug":"crop-type-must-be-one-of-list-crop-type-index-key","errorCode":null,"errorMessage":"crop_type must be one of {list(crop_type_index.keys())}","messagePattern":"crop_type must be one of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/sam3_inference_utils.py","lineNumber":663,"sourceCode":"    thumbnail_size: int = 3,\n) -> None:\n  \"\"\"Displays detection crops as a grid of labeled thumbnails.\n\n  Args:\n      crop_pairs: List of tuples from ``process_detections``, each containing\n        ``(detection_index, raw_crop, masked_crop, blended_crop)``.\n      state: SAM output dict containing ``'scores'``.\n      crop_type: Which crop to display. One of ``'raw'``, ``'masked'``,\n        ``'blended'``.\n      columns_per_row: Maximum number of thumbnails per row.\n      thumbnail_size: Size of each thumbnail in inches.\n\n  Raises:\n      ValueError: If ``crop_type`` is not one of the allowed values.\n  \"\"\"\n  crop_type_index = {\"raw\": 1, \"masked\": 2, \"blended\": 3}\n  if crop_type not in crop_type_index:\n    raise ValueError(f\"crop_type must be one of {list(crop_type_index.keys())}\")\n\n  idx = crop_type_index[crop_type]\n  valid_pairs = [pair for pair in crop_pairs if pair[idx] is not None]\n\n  total_crops = len(valid_pairs)\n  if total_crops == 0:\n    print(\"No valid crops to display.\")\n    return\n\n  num_columns = min(total_crops, columns_per_row)\n  num_rows = math.ceil(total_crops / num_columns)\n\n  _, axes = plt.subplots(\n      num_rows,\n      num_columns,\n      figsize=(num_columns * thumbnail_size, num_rows * thumbnail_size),\n  )\n","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/sam3_inference_utils.py#L645-L681","documentation":"Error \"crop_type must be one of {list(crop_type_index.keys())}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/sam3_inference_utils.py:663 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}