{"record":{"id":"f6caf70658583b33","repo":"roboflow/supervision","slug":"labelme-rectangle-shape-label-label-has-len-p","errorCode":null,"errorMessage":"LabelMe rectangle shape (label={label}) has {len(points)} point(s); expected at least 2.","messagePattern":"LabelMe rectangle shape \\(label=(.+?)\\) has (.+?) point\\(s\\); expected at least 2\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/dataset/formats/labelme.py","lineNumber":119,"sourceCode":"            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                )\n            xyxy = polygon_to_xyxy(polygon=points).astype(np.float32)\n            polygon = points\n        xyxy_list.append(xyxy)\n        class_ids.append(class_to_index[label])\n        if with_masks:\n            polygons.append(polygon)\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/dataset/formats/labelme.py#L101-L137","documentation":"Raised when a LabelMe rectangle shape has fewer than 2 points. A rectangle is defined by two corner points ([x1, y1] and [x2, y2]) which supervision converts to an xyxy box; with 0 or 1 points the box is underdetermined, so parsing aborts before _rectangle_to_xyxy.","triggerScenarios":"DetectionDataset.from_labelme where a shape with \"shape_type\": \"rectangle\" has \"points\": [] or a single [[x, y]] entry.","commonSituations":"Annotations saved mid-drawing (click without drag); converter bugs writing only one corner; hand-authored JSON with an empty points array; exports from tools that emit degenerate rectangles.","solutions":["Find the rectangle shape with <2 points in the failing JSON and add the second corner: [[x1, y1], [x2, y2]].","If the shape is an abandoned drawing artifact, delete that shape object entirely.","Fix the annotation-writing code to only persist completed rectangles."],"exampleFix":"// before\n{\"shape_type\": \"rectangle\", \"label\": \"dog\", \"points\": [[10, 10]]}\n// after\n{\"shape_type\": \"rectangle\", \"label\": \"dog\", \"points\": [[10, 10], [100, 140]]}","handlingStrategy":"validation","validationCode":"def rectangle_complete(shape: dict) -> bool:\n    \"\"\"A LabelMe rectangle needs at least two [x, y] points.\"\"\"\n    return shape.get('shape_type') != 'rectangle' or len(shape.get('points', [])) >= 2","typeGuard":null,"tryCatchPattern":"try:\n    dataset = sv.DetectionDataset.from_labelme(images_dir, ann_dir)\nexcept ValueError as e:\n    if 'rectangle' in str(e) and 'expected at least 2' in str(e):\n        raise SystemExit(f'Complete or remove the degenerate rectangle: {e}') from e\n    raise","preventionTips":["Discard unfinished drawings in annotation tooling (no single-click rectangles).","Validate rectangle shapes during export from custom tools.","Periodically lint annotation JSON for degenerate geometry."],"tags":["labelme","dataset","rectangle","json"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}