{"record":{"id":"54ac5cea1c8bd9cb","repo":"roboflow/supervision","slug":"labelme-shape-of-type-shape-type-label-label","errorCode":null,"errorMessage":"LabelMe shape of type {shape_type} (label={label}) has malformed points: expected an (N, 2) array, got shape {points.shape}.","messagePattern":"LabelMe shape of type (.+?) \\(label=(.+?)\\) has malformed points: expected an \\(N, 2\\) array, got shape (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/dataset/formats/labelme.py","lineNumber":112,"sourceCode":"    polygons: list[npt.NDArray[np.float32]] = []\n    skipped_types: set[str] = set()\n\n    for shape in shapes:\n        shape_type = shape.get(\"shape_type\")\n        if shape_type not in SUPPORTED_SHAPE_TYPES:\n            skipped_types.add(str(shape_type))\n            continue\n        label = shape.get(\"label\")\n        points_raw = shape.get(\"points\")\n        if label is None or points_raw is None:\n            missing = \"label\" if label is None else \"points\"\n            raise ValueError(\n                f\"LabelMe shape of type {shape_type!r} is missing the \"\n                f\"required {missing!r} field.\"\n            )\n        points = np.array(points_raw, dtype=np.float32)\n        if points.ndim != 2 or points.shape[1] != 2:\n            raise ValueError(\n                f\"LabelMe shape of type {shape_type!r} (label={label!r}) has \"\n                f\"malformed points: expected an (N, 2) array, got shape \"\n                f\"{points.shape}.\"\n            )\n        if shape_type == \"rectangle\":\n            if len(points) < 2:\n                raise ValueError(\n                    f\"LabelMe rectangle shape (label={label!r}) has \"\n                    f\"{len(points)} point(s); expected at least 2.\"\n                )\n            xyxy = _rectangle_to_xyxy(points)\n            polygon = _xyxy_to_polygon(xyxy)\n        else:\n            if len(points) < 3:\n                raise ValueError(\n                    f\"LabelMe polygon shape (label={label!r}) has \"\n                    f\"{len(points)} point(s); expected at least 3.\"\n                )","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/dataset/formats/labelme.py#L94-L130","documentation":"Raised when a LabelMe shape's points cannot be interpreted as an (N, 2) numeric array — np.array(points_raw, dtype=np.float32) yields a wrong ndim or second dimension. LabelMe stores points as a list of [x, y] pairs; a flat list of numbers, a list of triples, or ragged data fails this structural check with the actual shape reported.","triggerScenarios":"DetectionDataset.from_labelme where points is e.g. [1, 2, 3, 4] (flat), [[x, y, z]] (triples), or contains non-numeric entries causing an unexpected array shape after coercion.","commonSituations":"Scripts that emit flattened coordinates to save space; unit conversion code that flattens pairs; copy-paste from CSV where each point became a single string; 3D annotation tools writing extra columns.","solutions":["Look at the reported shape in the error: (N,) means flat pairs -> reshape to [[x, y], ...]; (N, 3) means extra columns -> drop them.","Fix the generator/converter to emit a list of [x, y] pairs.","If only a few shapes are bad, repair or delete them in the JSON directly."],"exampleFix":"// before\n\"points\": [10, 20, 30, 40]\n// after\n\"points\": [[10, 20], [30, 40]]","handlingStrategy":"validation","validationCode":"def points_are_pairs(points: object) -> bool:\n    \"\"\"LabelMe points must be a list of [x, y] pairs.\"\"\"\n    return (isinstance(points, list) and len(points) > 0\n            and all(isinstance(p, (list, tuple)) and len(p) == 2 for p in points))","typeGuard":null,"tryCatchPattern":"try:\n    dataset = sv.DetectionDataset.from_labelme(images_dir, ann_dir)\nexcept ValueError as e:\n    if 'malformed points' in str(e):\n        raise SystemExit(f'Reshape points to [[x, y], ...] in the named file: {e}') from e\n    raise","preventionTips":["Emit points as nested [x, y] lists from converters, never flat arrays.","Check for extra columns when converting from 3D tools.","Validate a sample of generated JSON with a schema check before bulk runs."],"tags":["labelme","dataset","json","shape"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}