feat(tagging): SigLIP concept crops + max-over-bag scoring (#114) #153
Reference in New Issue
Block a user
Delete Branch "feat/siglip-concept-crops"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Lifts recall on small/local concepts (glasses, cum, stomach-bulge, xray, lactation, …) that the whole-image SigLIP vector washes out. The GPU agent now embeds figure crops with SigLIP too (stored as
kind='concept'regions), and the suggestion rail scores each image as a bag — whole-image embedding + every concept crop — taking each head's max over the bag. The whole-image vector is always in the bag, so a score can never come out lower than today.Model-agnostic by construction
The server announces the embedding model (HF name + version) in the lease, so the agent loads whatever model the heads were trained in and stays in lock-step. A model swap is a server setting + a re-embed migration — never an agent change. (Caveat: pgvector columns are fixed-width, so a different output dim needs a column-resize migration; folds into the re-embed.)
Changes
Agent (outside CI; built by build-agent job)
embedder.py— model-agnosticCropEmbedder(torch/transformersget_image_features, fp16 on CUDA, inference-locked single shared instance).worker.py— branches onjob.task:ccip/bothemit figure(CCIP)+concept(SigLIP) in one pass;siglipemits concept-only so the back-catalogue backfill never churns figure/CCIP regions or the character-reference cache.requirements.txt+Dockerfile— torch from the cu124 wheel index + transformers.Server
api/gpu.py— lease announcesembed_model_name/embed_version.heads.score_image— max-over-bag (version-filtered region embeddings).tasks/ml.enqueue_gpu_backfill—siglipbranch gates on a missing concept region (drains the back-catalogue, retries failed embeds, no double-enqueue).celery_app— dailysiglipbackfill beat.api/ccip.overview— reportsimages_with_concept_siglip.Scope (v1)
Suggestion rail only. Auto-apply stays whole-image (conservative — heads' thresholds were calibrated on whole-image; max-over-bag can inflate scores, and rail extra-recall is operator-reviewed). Bulk-apply on bags is a documented follow-up.
Tests
test_ml_suggestions::test_concept_region_surfaces_via_max_over_bag— a crop aligned with a head lifts a sub-threshold whole-image score over the cut; a stale-version region is filtered out of the bag.test_gpu_jobs::test_enqueue_siglip_backfill_gates_on_concept_region— selection + idempotency.🤖 Generated with Claude Code