-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Union[Color, ColorPalette] to text_color parameter #1387
Conversation
Nice! Probably also needs |
Merge branch 'text_color_param' of https://github.com/Bhavay-2001/roboflow-supervision into text_color_param
…oflow-supervision into text_color_param
Hi @SkalskiP, pls review this one. |
supervision/annotators/core.py
Outdated
@@ -1050,6 +1055,7 @@ def annotate( | |||
detections: Detections, | |||
labels: Optional[List[str]] = None, | |||
custom_color_lookup: Optional[np.ndarray] = None, | |||
custom_text_color_lookup: Optional[np.ndarray] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the same custom_color_lookup
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Hi 👋🏻 @yeldarby and @Bhavay-2001. I don't think we need The spirit behind @Bhavay-2001 please apply these same changes to |
@@ -1369,7 +1382,7 @@ def annotate( | |||
xy=(text_x, text_y), | |||
text=text, | |||
font=self.font, | |||
fill=self.text_color.as_rgb(), | |||
fill=text_color.as_rgb(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this, do we need to change as_rgb()
to as_bgr()
same like we did in LabelAnnotator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RichLabelAnnotator
uses Pillow as a rendering engine. Pillow accepts colors in RGB order, while OpenCV in BGR. So we keep as_rgb()
here.
Hi @SkalskiP, please review the changes. |
Also, if this gets approved, can I start with #1383? I would like to know more about the issue. |
supervision/annotators/core.py
Outdated
@@ -1011,37 +1011,42 @@ class LabelAnnotator(BaseAnnotator): | |||
def __init__( | |||
self, | |||
color: Union[Color, ColorPalette] = ColorPalette.DEFAULT, | |||
text_color: Color = Color.WHITE, | |||
text_color: Union[Color, ColorPalette] = ColorPalette.LEGACY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestion: I think we should keep white as default because it changes readability and also change default behavior, up until this version we put "white" and when people see different color It can create some confusion. It would be better keep "Color.WHITE" as default but keep type change is "Union[Color, ColorPalette]" in case of multi color change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onuralpszr, yess certainly. I changed this because it was overlapping with ColorPalette.DEFAULT and the labels weren't visible but I will change it to White now.
Also, couldn't understand this but keep type change is "Union[Color, ColorPalette]" in case of multi color change.
Can you explain it further? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bhavay-2001 What I meant is finally It should look like this
text_color: Union[Color, ColorPalette] = Color.WHITE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong on this but I think there is no such method. Although, there is COLOR.WHITE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bhavay-2001 ah right I miss typed yes Color.WHITE
Hi @SkalskiP, this is open for reviewing now. |
@@ -1369,7 +1382,7 @@ def annotate( | |||
xy=(text_x, text_y), | |||
text=text, | |||
font=self.font, | |||
fill=self.text_color.as_rgb(), | |||
fill=text_color.as_rgb(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RichLabelAnnotator
uses Pillow as a rendering engine. Pillow accepts colors in RGB order, while OpenCV in BGR. So we keep as_rgb()
here.
supervision/annotators/core.py
Outdated
text_scale: float = 0.5, | ||
text_thickness: int = 1, | ||
text_padding: int = 10, | ||
text_position: Position = Position.TOP_LEFT, | ||
color_lookup: ColorLookup = ColorLookup.CLASS, | ||
text_color_lookup: ColorLookup = ColorLookup.CLASS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this parameter and use color_lookup
.
supervision/annotators/core.py
Outdated
font_path: Optional[str] = None, | ||
font_size: int = 10, | ||
text_padding: int = 10, | ||
text_position: Position = Position.TOP_LEFT, | ||
color_lookup: ColorLookup = ColorLookup.CLASS, | ||
text_color_lookup: ColorLookup = ColorLookup.CLASS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this parameter and use only color_lookup
.
@Bhavay-2001, thanks a lot for all the work. We are almost there. Just few small changes and we can merge. |
Done |
Tested here everything works. Merging! |
Description
Fix of issue #1384
Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
I will update with colab notebook once the changes are approved.
Any specific deployment considerations
Docs