fix: constrain trained head labels to enrolled catalog
This commit is contained in:
parent
b937be8e30
commit
2798322417
3 changed files with 184 additions and 23 deletions
|
|
@ -228,7 +228,7 @@ def train_from_stock(args) -> None:
|
|||
|
||||
import torch
|
||||
|
||||
from gallery import ProductGallery
|
||||
from gallery import DINOV2_MODEL, ProductGallery, catalog_digest, head_class_set
|
||||
|
||||
stock = args.stock
|
||||
report = enrollment_report(stock)
|
||||
|
|
@ -267,10 +267,15 @@ def train_from_stock(args) -> None:
|
|||
|
||||
projection, prototypes = train_head(features, augmented_labels, class_ids,
|
||||
args.epochs, device, margin=0.25)
|
||||
digest = catalog_digest(stock, class_ids)
|
||||
if head_class_set(class_ids) is None or digest is None:
|
||||
print(f"{stock}: refusing to write a head; class ids are empty or duplicated")
|
||||
return
|
||||
payload = {
|
||||
"class_ids": class_ids,
|
||||
"catalog_digest": digest,
|
||||
"image_size": 518,
|
||||
"base_model": "vit_small_patch14_dinov2.lvd142m",
|
||||
"base_model": DINOV2_MODEL,
|
||||
"projection": {key: value.cpu() for key, value in projection.state_dict().items()},
|
||||
"prototypes": prototypes.cpu(),
|
||||
"views": {sku: len(paths) for sku, paths in sorted(views.items())},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue