supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Added text_color parameter for VertexLabelAnnotator

Open Bhavay-2001 opened this issue 1 year ago • 10 comments

Description

Part of #1384

Type of change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

  1. Notebook

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • [ ] Docs updated? What were the changes:

Bhavay-2001 avatar Jul 26 '24 13:07 Bhavay-2001

Hi @SkalskiP, I have made the changes as per my understanding. In the VertexLabel class, it is running a for loop for different colors where there should be for text color too here

Soo I think it should add some function for adding multiple text_colors

Bhavay-2001 avatar Jul 26 '24 13:07 Bhavay-2001

Hi @SkalskiP @LinasKo pls review this PR. Thanks

Bhavay-2001 avatar Jul 30 '24 04:07 Bhavay-2001

Hi, @Bhavay-2001 👋🏻 Thanks a lot for your interest in supervision. It Looks like you added external API and docstring, but it looks like changing the value of text_color does not result in changing the text color per anchor :/ Am I missing something?

SkalskiP avatar Aug 05 '24 14:08 SkalskiP

Hi @SkalskiP, Yess, this was little bit incomplete.

The color parameter of the VertexLabelAnnotator is Union[Color, List[Color]]. Should we add this in text_color as well soo that we can use the same logic as in the color parameter?

Bhavay-2001 avatar Aug 06 '24 06:08 Bhavay-2001

Hi @Bhavay-2001 👋🏻 I'd even say we should make it the same as other annotators and make both color and text_color to be Union[Color, ColorPalette].

SkalskiP avatar Aug 06 '24 06:08 SkalskiP

Alright. Then, maybe we should take the this logic from other annotators.

Bhavay-2001 avatar Aug 06 '24 07:08 Bhavay-2001

If it's possible to reuse some parts of that logic, then sure.

SkalskiP avatar Aug 06 '24 09:08 SkalskiP

Before making the changes, I would like to discuss regarding this.

Currently, the color parameter in VertexLabelAnnotator accepts either single color or a list. If we change it to ColorPallette, then we need to make changes to this function -

def preprocess_and_validate_colors(
        colors: Optional[Union[Color, List[Color]]],
        points_count: int,
        skeletons_count: int,
    ) -> np.array:
        if isinstance(colors, list) and len(colors) != points_count:
            raise ValueError(
                f"Number of colors ({len(colors)}) must match number of key points "
                f"({points_count})."
            )
        return (
            np.array(colors * skeletons_count)
            if isinstance(colors, list)
            else np.array([colors] * points_count * skeletons_count)
        )

In this, we need to change the color parameter in function definition and then it will return a list of colors. Should I proceed with this?

Bhavay-2001 avatar Aug 06 '24 09:08 Bhavay-2001

@Bhavay-2001, after further consideration, let's not change the type for now. Keep color as either Color or List[Color] (let's not introduce ColorPalette yet). But let's make text_color also Color or List[Color].

SkalskiP avatar Aug 07 '24 11:08 SkalskiP

Hi @SkalskiP, please check the code and the notebook. Thanks

Bhavay-2001 avatar Aug 07 '24 17:08 Bhavay-2001

Done

Bhavay-2001 avatar Aug 13 '24 12:08 Bhavay-2001

Hi @Bhavay-2001, I've now approved the pull request and will merge it in. Thank you for the contribution.

However, it is also an example of a contribution we won't accept in the future. For a feature this small, the number of times we had to come back to verify, the number of mistakes we found, the number of questions we had to answer - that takes 5x time than it saves, especially for a feature this small. Looking back, this also holds true for #1387 and #1227.

LinasKo avatar Aug 14 '24 07:08 LinasKo