{"record":{"id":"9451cefbb6d1417f","repo":"tensorflow/models","slug":"the-masks-must-have-the-same-dimensions","errorCode":null,"errorMessage":"The masks must have the same dimensions.","messagePattern":"The masks must have the same dimensions\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/waste_identification_ml/data_generation/utils.py","lineNumber":206,"sourceCode":"\n\ndef _calculate_intersection_score(\n    elem1: dict[str, Any], elem2: dict[str, Any]\n) -> float:\n  \"\"\"Calculates the intersection score for two masks.\n\n  Args:\n    elem1: The first element.\n    elem2: The second element.\n\n  Returns:\n    The intersection score calculated as the ratio of the intersection\n    area to the area of the smaller mask.\n  \"\"\"\n\n  # Check if the masks have the same dimensions.\n  if elem1['segmentation'].shape != elem2['segmentation'].shape:\n    raise ValueError('The masks must have the same dimensions.')\n\n  min_elem = elem1 if elem1['area'] < elem2['area'] else elem2\n  intersection = np.logical_and(elem1['segmentation'], elem2['segmentation'])\n  score = np.sum(intersection) / np.sum(min_elem['segmentation'])\n  return score\n\n\ndef filter_nested_similar_masks(\n    elements: list[dict[str, Any]]\n) -> list[dict[str, Any]]:\n  \"\"\"Filters out nested masks from a list of elements.\n\n  Args:\n    elements: A list of dictionaries representing elements.\n\n  Returns:\n    A list of dictionaries representing elements with nested masks filtered out.\n  \"\"\"","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/waste_identification_ml/data_generation/utils.py#L188-L224","documentation":"Error \"The masks must have the same dimensions.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/waste_identification_ml/data_generation/utils.py:206 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"}