{"record":{"id":"90ec55deff41cd85","repo":"keras-team/keras","slug":"there-are-unsupported-keys-in-bounding-boxes-l","errorCode":null,"errorMessage":"There are unsupported keys in `bounding_boxes`: {list(extra_keys)}. Only `boxes` and `labels` are supported.","messagePattern":"There are unsupported keys in `bounding_boxes`: (.+?)\\. Only `boxes` and `labels` are supported\\.","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/image_preprocessing/max_num_bounding_box.py","lineNumber":98,"sourceCode":"        boxes = ops.numpy.reshape(boxes, [batch_size, self.max_number, 4])\n        labels = ops.numpy.reshape(labels, [batch_size, self.max_number])\n\n        bounding_boxes = bounding_boxes.copy()\n        bounding_boxes[\"boxes\"] = boxes\n        bounding_boxes[\"labels\"] = labels\n        return bounding_boxes\n\n    def transform_segmentation_masks(\n        self, segmentation_masks, transformation=None, training=True\n    ):\n        return self.transform_images(segmentation_masks)\n\n    def compute_output_shape(self, input_shape):\n        if isinstance(input_shape, dict) and \"bounding_boxes\" in input_shape:\n            input_keys = set(input_shape[\"bounding_boxes\"].keys())\n            extra_keys = input_keys - set((\"boxes\", \"labels\"))\n            if extra_keys:\n                raise KeyError(\n                    \"There are unsupported keys in `bounding_boxes`: \"\n                    f\"{list(extra_keys)}. \"\n                    \"Only `boxes` and `labels` are supported.\"\n                )\n\n            boxes_shape = list(input_shape[\"bounding_boxes\"][\"boxes\"])\n            boxes_shape[1] = self.max_number\n            labels_shape = list(input_shape[\"bounding_boxes\"][\"labels\"])\n            labels_shape[1] = self.max_number\n            input_shape[\"bounding_boxes\"][\"boxes\"] = boxes_shape\n            input_shape[\"bounding_boxes\"][\"labels\"] = labels_shape\n        return input_shape\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\"max_number\": self.max_number})\n        return config\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/image_preprocessing/max_num_bounding_box.py#L80-L116","documentation":"MaxNumBoundingBoxes.compute_output_shape only accepts 'boxes' and 'labels' keys inside the bounding_boxes dict. Extra keys such as 'confidence', 'num_classes', or custom metadata raise a KeyError before shape computation.","triggerScenarios":"Building a model whose input spec includes {'bounding_boxes': {'boxes': ..., 'labels': ..., 'confidence': ...}} and passing it to this layer's compute_output_shape / model build.","commonSituations":"Detection pipelines that carry extra per-box metadata alongside labels; converting a COCO-style annotation dict directly to layer input without pruning keys; version changes that tightened accepted keys.","solutions":["Strip extra keys before feeding the layer: bbs = {'boxes': bbs['boxes'], 'labels': bbs['labels']}","Carry auxiliary metadata (scores, difficulty flags) outside the bounding_boxes dict, in a parallel structure","If you need confidences, fold them into labels or a separate input"],"exampleFix":"# before\nbbs = {'boxes': boxes, 'labels': labels, 'confidence': confs}\n# after\nbbs = {'boxes': boxes, 'labels': labels}\nconfs_outside = confs","handlingStrategy":"validation","validationCode":"allowed = {'boxes', 'labels'}\nextra = set(bbs) - allowed\nif extra:\n    bbs = {k: bbs[k] for k in allowed}\n# keep extras separately\nextras = {k: v for k, v in bbs_orig.items() if k not in allowed}","typeGuard":"def has_only_supported_keys(bbs):\n    return set(bbs) <= {'boxes', 'labels'}","tryCatchPattern":null,"preventionTips":["Keep auxiliary per-box data outside the bounding_boxes dict","Prune annotation dicts to boxes/labels before model input"],"tags":["keras","bounding-boxes","dict-keys","preprocessing"],"backgroundTag":"schema-validation-failed","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}