roboflow/supervision · error · ValueError

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

Error message

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

What it means

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

Source

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

                element is an integer in the range 0-255.

        Returns:
            An instance representing the color.

        Raises:
            ValueError: If any RGBA value is outside the range 0-255.

        Example:
            ```pycon
            >>> import supervision as sv
            >>> sv.Color.from_rgba_tuple((255, 255, 0, 128))
            Color(r=255, g=255, b=0, a=128)

            ```
        """
        r, g, b, a = color_tuple
        if not (0 <= r <= 255 and 0 <= g <= 255 and 0 <= b <= 255 and 0 <= a <= 255):
            raise ValueError(
                f"RGBA values must be in range 0-255, got ({r}, {g}, {b}, {a})"
            )
        return cls(r=r, g=g, b=b, a=a)

    @classmethod
    def from_bgra_tuple(cls, color_tuple: tuple[int, int, int, int]) -> Color:
        """
        Create a Color instance from a BGRA tuple.

        Args:
            color_tuple: A tuple representing the color in BGRA format, where each
                element is an integer in the range 0-255.

        Returns:
            An instance representing the color.

        Raises:
            ValueError: If any BGRA value is outside the range 0-255.

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Pass r, g, b, a values each between 0 and 255 to Color.from_rgba.
  2. Validate or clamp values before calling if they come from an external source.

When it happens

Trigger: Thrown at src/supervision/draw/color.py:240 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/e0dbb57f1a870242. Report an issue: GitHub.