Skip to content

Conversation

@safa0
Copy link

@safa0 safa0 commented Sep 9, 2025

Summary

This PR adds support for displaying scores/confidence values on shapes in the labelme annotation tool.

Changes

  • Added _draw_score_text() method to the Shape class
  • Shapes can now display text scores from other_data['score_text']
  • Score text is rendered in the upper-left corner of the shape's bounding box
  • Text has a semi-transparent white background for better readability
  • Uses 10pt bold font with black text

Use Case

This feature is useful for:

  • Displaying confidence scores from ML model predictions
  • Showing detection scores when importing pre-labeled data
  • Adding any numerical or text metadata to be displayed on shapes

Implementation Details

The score display:

  • Only renders when score_text exists in the shape's other_data dictionary
  • Positions text in upper-left corner with 3px padding
  • Includes semi-transparent background (rgba: 255, 255, 255, 200)
  • Scales properly with zoom level
  • Restores original painter pen after drawing

Screenshots

The score text appears as a small label in the upper-left corner of annotated shapes when other_data['score_text'] is set.

- Using "other_data" to show, e.g. scoring when shapes
  are used for auto annotation.

def _draw_score_text(self, painter):
"""Draw score text in the upper-left corner of shape's bounding box."""
score_text = self.other_data.get('score_text', '')
Copy link
Owner

@wkentaro wkentaro Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't read from other_data, so this has to be other way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first added a score specific field, but then thought we already have "other_data", what do you suggest? a specific "score" field per shape?

Copy link
Owner

@wkentaro wkentaro Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably steps would be like:

  1. add a capability to draw label (or label + groupid)
  2. add a dropdown to select what field to show (supports flags, other_data, etc)

?

I am for the direction, it clearly adds value.

@safa0 safa0 force-pushed the show-scoring-on-shapes branch 2 times, most recently from 11ea091 to 85bdc5f Compare September 12, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants