In Supervision, is there a way to configure the color/colors the annotator uses?
Ex: how was this image set to only annotate purple bounding boxes?
In Supervision, is there a way to configure the color/colors the annotator uses?
Ex: how was this image set to only annotate purple bounding boxes?
You can change the color of most, if not all, Supervision annotators by specifying a color
parameter and supplying a supervision.Color
or supervision.ColorPalette
object.
You can create a Color
by using the from_hex
method like so:
color = supervision.Color.from_hex("#fff") # For a white hex code
or from a RGB color:
color = supervision.Color(0,0,0) # Equivilant to an RGB code of (0,0,0)
You can also create a ColorPalette
using the from_hex
method:
color_palette = supervision.ColorPalette.from_hex(["#fff", "#000"])
or you can also create a ColorPalette
by supplying a list of Color
objects:
# In this example, the supervision name is shortened to `sv` which you can do using `import supervision as sv`
color_palette = sv.ColorPalette([sv.Color(0,0,0), sv.Color(255,255,255)])
For example, in the BoundingBoxAnnotator
(as seen in the example image), you can set the color property to purple like we showed previously:
color = supervision.Color.from_hex("#9C66E9")
bounding_box_annotator = supervision.BoundingBoxAnnotator(color=color)