{"record":{"id":"44f136cd12617b76","repo":"keras-team/keras","slug":"encoding-format-should-be-one-of-center-xywh-o","errorCode":null,"errorMessage":"`encoding_format` should be one of 'center_xywh' or 'center_yxhw', got {encoding_format}","messagePattern":"`encoding_format` should be one of 'center_xywh' or 'center_yxhw', got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/converters.py","lineNumber":308,"sourceCode":"            `image_shape` is used for normalization.\n    Returns:\n        Encoded box deltas. The return type matches the `encode_format`.\n\n    Raises:\n        ValueError: If `variance` is not None and its length is not 4.\n        ValueError: If `encoding_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 encoding_format not in [\"center_xywh\", \"center_yxhw\"]:\n        raise ValueError(\n            \"`encoding_format` should be one of 'center_xywh' or \"\n            f\"'center_yxhw', got {encoding_format}\"\n        )\n\n    if image_shape is None:\n        height, width = None, None\n    else:\n        height, width, _ = image_shape\n\n    encoded_anchors = convert_format(\n        anchors,\n        source=anchor_format,\n        target=encoding_format,\n        height=height,\n        width=width,\n    )\n    boxes = convert_format(\n        boxes,","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/converters.py#L290-L326","documentation":"encode_box_to_deltas supports two delta encoding formats: 'center_xywh' (center x, y, width, height) and 'center_yxhw' (center y, x, height, width). Any other encoding_format string is rejected with this ValueError before any computation happens.","triggerScenarios":"Passing encoding_format='xyxy', 'corner', 'centroid', or a typo like 'center_xyw'.","commonSituations":"Assuming the encoder accepts the same format names as other converters in the module (e.g. 'centers' or 'xywh'); mixing up this function's format names with those of other converters.","solutions":["Use encoding_format='center_xywh' or 'center_yxhw'.","If boxes are in corner format, convert them first, or use a different converter suited to xyxy."],"exampleFix":"# before\ndeltas = encode_box_to_deltas(boxes, anchors, encoding_format=\"xywh\")\n# after\ndeltas = encode_box_to_deltas(boxes, anchors, encoding_format=\"center_xywh\")","handlingStrategy":"type-guard","validationCode":"assert encoding_format in (\"center_xywh\", \"center_yxhw\"), f\"bad encoding_format {encoding_format!r}\"","typeGuard":"def is_valid_encoding_format(f):\n    return f in {\"center_xywh\", \"center_yxhw\"}\n","tryCatchPattern":null,"preventionTips":["Use an Enum or module constants for encoding format names."],"tags":["keras","bounding-boxes","encoding","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"}