{"record":{"id":"d2d55fa665478f9d","repo":"keras-team/keras","slug":"encoded-format-should-be-center-xywh-or-cente","errorCode":null,"errorMessage":"`encoded_format` should be 'center_xywh' or 'center_yxhw', but got '{encoded_format}'.","messagePattern":"`encoded_format` should be 'center_xywh' or 'center_yxhw', but got '(.+?)'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/converters.py","lineNumber":404,"sourceCode":"\n    Returns:\n        Decoded box coordinates. The return type matches the `box_format`.\n\n    Raises:\n        ValueError: If `variance` is not None and its length is not 4.\n        ValueError: If `encoded_format` is not `\"center_xywh\"` or\n            `\"center_yxhw\"`.\n\n    \"\"\"\n    if variance is not None:\n        variance = ops.convert_to_tensor(variance, \"float32\")\n        var_len = variance.shape[-1]\n\n        if var_len != 4:\n            raise ValueError(f\"`variance` must be length 4, got {variance}\")\n\n    if encoded_format not in [\"center_xywh\", \"center_yxhw\"]:\n        raise ValueError(\n            f\"`encoded_format` should be 'center_xywh' or 'center_yxhw', \"\n            f\"but got '{encoded_format}'.\"\n        )\n\n    if image_shape is None:\n        height, width = None, None\n    else:\n        height, width, _ = image_shape\n\n    def decode_single_level(anchor, box_delta):\n        encoded_anchor = convert_format(\n            anchor,\n            source=anchor_format,\n            target=encoded_format,\n            height=height,\n            width=width,\n        )\n        if variance is not None:","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/converters.py#L386-L422","documentation":"decode_deltas_to_boxes accepts only two encoded formats: 'center_xywh' and 'center_yxhw'. The encoded_format must match the format used when the deltas were produced; any other string raises this ValueError.","triggerScenarios":"Passing encoded_format='xywh', 'corner', or forgetting the argument when deltas were produced with a custom encoder.","commonSituations":"Encode side used 'center_yxhw' but decode side copies 'center_xywh' or vice versa; renaming format constants mid-project.","solutions":["Set encoded_format to exactly the format used at encode time: 'center_xywh' or 'center_yxhw'.","Store the encoding format alongside the deltas/anchors in checkpoints or configs so both ends agree."],"exampleFix":"# before\nboxes = decode_deltas_to_boxes(deltas, anchors, encoded_format=\"xywh\")\n# after\nboxes = decode_deltas_to_boxes(deltas, anchors, encoded_format=\"center_xywh\")","handlingStrategy":"validation","validationCode":"assert encoded_format in (\"center_xywh\", \"center_yxhw\"), f\"bad encoded_format {encoded_format!r}\"","typeGuard":"def is_valid_encoding_format(f):\n    return f in {\"center_xywh\", \"center_yxhw\"}\n","tryCatchPattern":null,"preventionTips":["Persist the encoding format string with checkpoints so decode uses the same one as encode."],"tags":["keras","bounding-boxes","decoding","invalid-enum-argument"],"backgroundTag":"invalid-enum-argument","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}