feat: a store's fine-tuned head, and the two-stage gate it needs
The head is now part of a store rather than a script: `finetune_identity.py --stock stock-lopia` trains on that store's enrolled views (27 views over 7 products, 12 augmented copies each) and writes `<stock>/identity_head.pt`, which ProductGallery loads automatically. The first attempt exposed a trap worth recording. A discriminative head has no "none of the above": trained with an angular margin to separate seven products, it maps everything confidently onto those seven, including cartons it has never seen. raw features, threshold 0.55 home shelf 78% accepted foreign shelves 5% accepted trained head, threshold 0.40 home shelf 58% accepted foreign shelves 44% accepted Rejection - the gallery's whole point - disappears. The fix needs no retraining: the two mechanisms fail in opposite directions, so raw features decide *whether* to answer (they generalise) and the head decides *what* to answer (it discriminates). Measured: 47% accepted on the home shelf, 5% on foreign ones. Lower coverage than raw-only, which is the honest trade. The head also needs its own threshold (0.40 against the raw 0.55): a trained head's similarity scale is its own, and reusing the raw line rejected almost everything it said. 175 tests pass. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
4fd5059ef0
commit
2bf916f2aa
4 changed files with 192 additions and 2 deletions
|
|
@ -232,3 +232,54 @@ What is settled is the mechanism: **a head trained on labels the pipeline can pr
|
|||
itself** - tag-named facings, plus operator confirmations - moves fine-grained
|
||||
identity from useless to usable, and a rejection threshold turns it into something a
|
||||
store can act on.
|
||||
|
||||
|
||||
---
|
||||
|
||||
# Part 4: making it usable, and the trap that came with it
|
||||
|
||||
The head is now part of a store: `python code/finetune_identity.py --stock stock-lopia`
|
||||
trains on that store's enrolled views and writes `<stock>/identity_head.pt`, which
|
||||
`ProductGallery` loads automatically. The first attempt exposed a trap worth writing
|
||||
down.
|
||||
|
||||
## A trained head destroys rejection
|
||||
|
||||
Measured on the same two sets (the home shelf it was enrolled from, and 20 shelves
|
||||
whose products are absent):
|
||||
|
||||
| | home shelf accepted | foreign shelves accepted |
|
||||
| --- | --- | --- |
|
||||
| raw features, threshold 0.55 | 78 % | **5 %** |
|
||||
| trained head, threshold 0.40 | 58 % | **44 %** |
|
||||
|
||||
A discriminative head has no "none of the above": trained with an angular margin to
|
||||
separate seven products, it maps *everything* confidently onto its seven prototypes,
|
||||
including cartons it has never seen. Rejection, which was the gallery's whole point,
|
||||
disappears.
|
||||
|
||||
## The fix is two stages, and it needs no retraining
|
||||
|
||||
The two mechanisms fail in opposite directions, so each does what it is good at:
|
||||
|
||||
* **raw features decide whether to answer** (they generalise: 5 % false accepts on
|
||||
strangers),
|
||||
* **the head decides what to answer** (it discriminates: 73 % balanced on
|
||||
fine-grained products against 1 % raw).
|
||||
|
||||
| | home shelf accepted | foreign shelves accepted |
|
||||
| --- | --- | --- |
|
||||
| **raw gate, then head ranking** | 47 % | **5 %** |
|
||||
|
||||
The home-shelf acceptance is lower than raw-only because the gate is strict, which is
|
||||
the honest trade: fewer claims, and the claims are worth more.
|
||||
|
||||
## Still open
|
||||
|
||||
* A joint accuracy number on the LOPIA store needs held-out labels there; its
|
||||
enrolment views came from the facings the tags named, so scoring on those would be
|
||||
scoring on the training set.
|
||||
* Training the head *with* out-of-distribution negatives (crops from other stores)
|
||||
should let it keep rejecting on its own, which would remove the need for the gate.
|
||||
* Everything above is still one photograph per store. The second visit remains the
|
||||
measurement that settles it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue