Skip to content

Comments

Add functionality to store label colors in annotations#23

Merged
felixT2K merged 4 commits intomainfrom
feature/label-color-persistence
Feb 17, 2026
Merged

Add functionality to store label colors in annotations#23
felixT2K merged 4 commits intomainfrom
feature/label-color-persistence

Conversation

@simont2k
Copy link
Contributor

  • add type_color_mapping to annotations so that the same colors are used for the same classes even across separate labeling sessions
  • update color generation to
    • avoid using colors similar to red (used for "words") for KIE labels
    • alternate between colors that are relatively easy to distinguish to avoid confusion between adjacent label types

Copy link
Collaborator

@felixdittrich92 felixdittrich92 left a comment

Choose a reason for hiding this comment

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

@simont2k

We should add/extend also the unittests
Especially for the saving / loading part

labels = annotations.get("labels", ["" for _ in polygons])
types = annotations.get("types", [self.root.type_options[0]] * len(polygons))
type_color_mapping = annotations.get("type_color_mapping", {})

Copy link
Collaborator

Choose a reason for hiding this comment

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

self.update_types is not required anymore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, not required anymore (colors for known types are set in _update_color_palette, gray is used for unknown types)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then let's remove this method

@felixdittrich92
Copy link
Collaborator

Have you performed any manual tests ?

  • Setting new types
  • Changing types
  • saving / loading

@simont2k
Copy link
Contributor Author

Have you performed any manual tests ?

* Setting new types

* Changing types

* saving / loading

Yes, I did various manual tests:

  • deleting color mapping entries in the annotation JSON during an annotation session will be overwritten by clicking "save" in the GUI application
  • manually overwriting a color in the annotation file is possible (will be used on next start / load of GUI application)
  • if a class is listed in annotations, but not in text_types in the starter script, it will be colored in gray (#808080) by default
    • the user should either update the type through the GUI or add the missing type to the starter script
  • changing names in starter script will re-generate the colors, using an algorithm to choose different colors for adjacent types
    • name changes do not have side effects
    • changing the order will shift the color mapping
      • types should not be removed (better: change name to mark them as unused)
      • new types should be added to the end of the list

Copy link
Collaborator

@felixdittrich92 felixdittrich92 left a comment

Choose a reason for hiding this comment

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

2 small things left then we are good to merge 👍

python -m pip install --upgrade pip
pip install -e . --upgrade
- name: Import package
# MacOS: use parseq as recognition architecture to avoid the onnxruntime error
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the following would be better: (with a comment)

- name: Set recognition arch for macOS
  if: matrix.os == 'macos-latest'
  run: echo "RECOGNITION_ARCH=parseq" >> $GITHUB_ENV

@simont2k simont2k force-pushed the feature/label-color-persistence branch 2 times, most recently from e3b2bb1 to ed7a296 Compare February 17, 2026 08:47
@simont2k simont2k force-pushed the feature/label-color-persistence branch from ed7a296 to 3c9647b Compare February 17, 2026 08:50
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 87.17949% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.94%. Comparing base (7afc764) to head (3c9647b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
labeler/views/canvas.py 75.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   87.01%   87.94%   +0.92%     
==========================================
  Files           9        9              
  Lines         901      929      +28     
==========================================
+ Hits          784      817      +33     
+ Misses        117      112       -5     
Flag Coverage Δ
unittests 87.94% <87.17%> (+0.92%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@felixT2K felixT2K left a comment

Choose a reason for hiding this comment

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

Thanks 👍🏼

@felixT2K felixT2K merged commit 6554675 into main Feb 17, 2026
23 checks passed
@felixT2K felixT2K deleted the feature/label-color-persistence branch February 17, 2026 10:24
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.

3 participants