roboflow/supervision · error · ValueError

Color values must be in range 0-255, got ({self.r}, {self.g}

Error message

Color values must be in range 0-255, got ({self.r}, {self.g}, {self.b}, {self.a})

What it means

Error "Color values must be in range 0-255, got ({self.r}, {self.g}, {self.b}, {self.a})" thrown in roboflow/supervision.

Source

Thrown at src/supervision/draw/color.py:111

    | `BLUE`     | `#0000FF`  | `(0, 0, 255)`     |
    | `YELLOW`   | `#FFFF00`  | `(255, 255, 0)`   |
    | `ROBOFLOW` | `#A351FB`  | `(163, 81, 251)`  |
    """

    r: int
    g: int
    b: int
    a: int = 255

    def __post_init__(self) -> None:
        """Validate that direct Color construction uses byte-sized channels."""
        if not (
            0 <= self.r <= 255
            and 0 <= self.g <= 255
            and 0 <= self.b <= 255
            and 0 <= self.a <= 255
        ):
            raise ValueError(
                "Color values must be in range 0-255, "
                f"got ({self.r}, {self.g}, {self.b}, {self.a})"
            )

    @classmethod
    def from_hex(cls, color_hex: str) -> Color:
        """
        Create a Color instance from a hex string.

        Args:
            color_hex: The hex string representing the color. This string can
                start with '#' followed by 3, 4, 6, or 8 hexadecimal characters.
                For 3- or 4-character codes, each character is doubled to form the
                full hex code.

        Returns:
            An instance representing the color.

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Construct the color with r, g, b, a values each in the 0-255 range.
  2. Clamp or scale float color values (e.g. multiply 0-1 floats by 255) before constructing the Color.

When it happens

Trigger: Thrown at src/supervision/draw/color.py:111 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/5704613c98d67903. Report an issue: GitHub.