{"record":{"id":"5ab6f6e890250351","repo":"keras-team/keras","slug":"invalid-start-points-shape-expected-4-2-for-a-s-5ab6f6","errorCode":null,"errorMessage":"Invalid start_points shape: expected (4,2) for a single image or (N,4,2) for a batch. Received shape: {start_points.shape}","messagePattern":"Invalid start_points shape: expected \\(4,2\\) for a single image or \\(N,4,2\\) for a batch\\. Received shape: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/image.py","lineNumber":686,"sourceCode":"    start_points = convert_to_tensor(start_points)\n    end_points = convert_to_tensor(end_points)\n\n    if interpolation not in AFFINE_TRANSFORM_INTERPOLATIONS:\n        raise ValueError(\n            \"Invalid value for argument `interpolation`. Expected of one \"\n            f\"{AFFINE_TRANSFORM_INTERPOLATIONS}. Received: \"\n            f\"interpolation={interpolation}\"\n        )\n\n    if len(images.shape) not in (3, 4):\n        raise ValueError(\n            \"Invalid images rank: expected rank 3 (single image) \"\n            \"or rank 4 (batch of images). Received input with shape: \"\n            f\"images.shape={images.shape}\"\n        )\n\n    if start_points.ndim not in (2, 3) or start_points.shape[-2:] != (4, 2):\n        raise ValueError(\n            \"Invalid start_points shape: expected (4,2) for a single image\"\n            f\" or (N,4,2) for a batch. Received shape: {start_points.shape}\"\n        )\n    if end_points.ndim not in (2, 3) or end_points.shape[-2:] != (4, 2):\n        raise ValueError(\n            \"Invalid end_points shape: expected (4,2) for a single image\"\n            f\" or (N,4,2) for a batch. Received shape: {end_points.shape}\"\n        )\n    if start_points.shape != end_points.shape:\n        raise ValueError(\n            \"start_points and end_points must have the same shape.\"\n            f\" Received start_points.shape={start_points.shape}, \"\n            f\"end_points.shape={end_points.shape}\"\n        )\n\n    input_dtype = images.dtype\n    if input_dtype == \"float16\":\n        images = images.astype(\"float32\")","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/image.py#L668-L704","documentation":"Shape guard in `perspective_transform` (NumPy backend): the source quadrilateral `start_points` must describe 4 corners as a (4, 2) array for a single image or an (N, 4, 2) batch. The guard checks both the ndim (2 or 3) and that the trailing shape equals (4, 2); wrong corner counts, missing coordinate pairs, or an extra/missing batch axis trigger it, with the actual shape shown.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/image.py:686 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide exactly four (x, y) corner pairs: start_points of shape (4, 2), or (N, 4, 2) for batches","Check for dropped coordinate axes: points stored as (4,) or (2, 4) must be reshaped to (4, 2)","Ensure batched images (rank 4) get batched start_points and single images (rank 3) get a single quadrilateral"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}