Add mask annotation to Annotate tab, colored to match boxes
John Ho+1: Claude Opus 4.8 (1M context)
93754f2
Overlay per-object segmentation masks (base64-PNG under `b64_mask`) beneath
each bounding box, using the same color as the box so an object's mask and box
always match. Masks draw whenever the mask key is present; clearing the key
disables them.
- pilbox.im_color_mask: fix int64->uint8 mask coercion (Image.fromarray
rejected the bool*int product), fix shape guard (shape[:1] -> shape[:2]),
rename rbg_tup -> rgb_tup, add Google docstring + doctest.
- pilbox.annotate: add mask_key/mask_alpha; pre-assign colors per object so
masks (drawn first, underneath) and boxes share one color.
- app.py: expose Mask key + Mask opacity inputs on the Annotate tab; MCP tool
schema verified intact.
- annotate_cli.py / annotate_file: add --mask-key / --mask-alpha parity.
- tests: cover the bug fixes and box/mask color consistency.
- pyproject/uv.lock: add pytest as a dev dependency.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Turn pilbox into a lite bbox annotation module with a CLI
John Ho+1: Claude Opus 4.8 (1M context)
df4e114
Rewrite pilbox.py as a standalone, importable bounding-box annotation
module depending only on numpy + Pillow + loguru (drop the broken
matplotlib.colors reference and add a proper import block).
- annotate(): main entry point using pascal_voc {x0,y0,x1,y1} boxes,
returns an annotated copy, configurable label/color keys
- palette_color()/color_for(): unbounded golden-angle HSV palette
replacing the matplotlib color logic
- im_draw_bbox(): filled label tab above the box top-left corner
- keep im_crop/im_center_crop/im_draw_point/load_pil_font for later
Add annotate_cli.py (typer + loguru) to annotate an image from a JSON
file, tests/ with unit tests + doctests, example assets, and update
CLAUDE.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>