{"record":{"id":"e2dc60211048d639","repo":"keras-team/keras","slug":"start-points-and-end-points-must-have-the-same-sha-e2dc60","errorCode":null,"errorMessage":"start_points and end_points must have the same shape. Received start_points.shape={start_points.shape}, end_points.shape={end_points.shape}","messagePattern":"start_points and end_points must have the same shape\\. Received start_points\\.shape=(.+?), end_points\\.shape=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/image.py","lineNumber":696,"sourceCode":"    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\")\n\n    need_squeeze = False\n    if len(images.shape) == 3:\n        images = np.expand_dims(images, axis=0)\n        need_squeeze = True\n\n    if len(start_points.shape) == 2:\n        start_points = np.expand_dims(start_points, axis=0)\n    if len(end_points.shape) == 2:\n        end_points = np.expand_dims(end_points, axis=0)","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/image.py#L678-L714","documentation":"Consistency guard in `perspective_transform` (NumPy backend): the homography is solved by pairing each start corner with the corresponding end corner, so the two point sets must have identical shapes (same batch size and same quadrilateral layout). After both individual shape checks pass, this final guard compares start_points.shape with end_points.shape and reports both when they differ.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/image.py:696 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make end_points the same shape as start_points, e.g. (N, 4, 2) for both","Broadcast a single quadrilateral to a batch: keras.ops.broadcast_to or np.repeat when only one destination is used for N images","Audit point-generation code so both arrays are built with the same stacking logic"],"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"}