roboflow/supervision · error · ValueError

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

Error message

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

What it means

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

Source

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

                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.

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

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

    def as_hex(self) -> str:
        """
        Converts the Color instance to a hex string.

        Returns:
            The hexadecimal color string. Returns `#RRGGBBAA` if alpha is not 255,
                otherwise returns `#RRGGBB`.

        Example:
            ```pycon
            >>> import supervision as sv
            >>> sv.Color(r=255, g=255, b=0).as_hex()
            '#ffff00'

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Pass b, g, r, a values each between 0 and 255 to Color.from_bgra.
  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:270 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/fa028fa37dfb8d78. Report an issue: GitHub.