roboflow/supervision · error · ValueError
LabelMe rectangle shape (label={label}) has {len(points)} po
Error message
LabelMe rectangle shape (label={label}) has {len(points)} point(s); expected at least 2. What it means
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.
Source
Thrown at src/supervision/dataset/formats/labelme.py:119
continue
label = shape.get("label")
points_raw = shape.get("points")
if label is None or points_raw is None:
missing = "label" if label is None else "points"
raise ValueError(
f"LabelMe shape of type {shape_type!r} is missing the "
f"required {missing!r} field."
)
points = np.array(points_raw, dtype=np.float32)
if points.ndim != 2 or points.shape[1] != 2:
raise ValueError(
f"LabelMe shape of type {shape_type!r} (label={label!r}) has "
f"malformed points: expected an (N, 2) array, got shape "
f"{points.shape}."
)
if shape_type == "rectangle":
if len(points) < 2:
raise ValueError(
f"LabelMe rectangle shape (label={label!r}) has "
f"{len(points)} point(s); expected at least 2."
)
xyxy = _rectangle_to_xyxy(points)
polygon = _xyxy_to_polygon(xyxy)
else:
if len(points) < 3:
raise ValueError(
f"LabelMe polygon shape (label={label!r}) has "
f"{len(points)} point(s); expected at least 3."
)
xyxy = polygon_to_xyxy(polygon=points).astype(np.float32)
polygon = points
xyxy_list.append(xyxy)
class_ids.append(class_to_index[label])
if with_masks:
polygons.append(polygon)
View on GitHub (pinned to 7f254d9784)
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.
Example fix
// before
{"shape_type": "rectangle", "label": "dog", "points": [[10, 10]]}
// after
{"shape_type": "rectangle", "label": "dog", "points": [[10, 10], [100, 140]]} Defensive patterns
Strategy: validation
Validate before calling
def rectangle_complete(shape: dict) -> bool:
"""A LabelMe rectangle needs at least two [x, y] points."""
return shape.get('shape_type') != 'rectangle' or len(shape.get('points', [])) >= 2 Try / catch
try:
dataset = sv.DetectionDataset.from_labelme(images_dir, ann_dir)
except ValueError as e:
if 'rectangle' in str(e) and 'expected at least 2' in str(e):
raise SystemExit(f'Complete or remove the degenerate rectangle: {e}') from e
raise Prevention
- 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.
When it happens
Trigger: DetectionDataset.from_labelme where a shape with "shape_type": "rectangle" has "points": [] or a single [[x, y]] entry.
Common situations: 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.
Related errors
- LabelMe shape of type {shape_type} is missing the required {
- LabelMe shape of type {shape_type} (label={label}) has malfo
- A LabelMe annotation file is missing the required 'imagePath
- LabelMe annotation has an invalid 'imagePath' {raw_image_pat
- LabelMe annotation for {image_name} requires 'imageWidth' an
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/f6caf70658583b33.
Report an issue: GitHub.