"""Run local tensor-fixture checks after downloading this model repository.""" import json from pathlib import Path import numpy as np import torch from spatial_caption_router import SpatialCaptionRouter root=Path(__file__).resolve().parent torch.set_num_threads(2) router=SpatialCaptionRouter.from_pretrained(root) with np.load(root/'parity-fixtures.npz',allow_pickle=False) as f: values=[torch.from_numpy(f[k]) for k in ('global_image','object_embedding','local_tokens','coords','coverage')] prediction=router.score_from_features(*values).numpy() error=float(np.max(np.abs(prediction-f['expected_score_over_5']))) assert error<3e-7 print(json.dumps({'status':'passed','fixtures':len(prediction),'score_max_abs_error':error, 'phone_runtime_tested':False},indent=2))