Download verify.py from ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0/resolve/main/verify.py
- Command line
-
hf download hf://ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0/verify.py
-
curl -L -o verify.py https://huggingface.co/ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0/resolve/main/verify.py
798 Bytes
| """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)) | |