Download scripts/verify_release.py from DiscoSea/vmr3D: direct link, hf CLI and curl.
- Browser
- Download file 1.97 kB
-
https://huggingface.co/DiscoSea/vmr3D/resolve/main/scripts/verify_release.py
- Command line
-
hf download hf://DiscoSea/vmr3D/scripts/verify_release.py
-
curl -L -o verify_release.py https://huggingface.co/DiscoSea/vmr3D/resolve/main/scripts/verify_release.py
1.97 kB
| """Check downloaded release artifacts using only Python's standard library.""" | |
| from pathlib import Path | |
| from html.parser import HTMLParser | |
| from urllib.parse import urlsplit,unquote | |
| import hashlib,json | |
| ROOT=Path(__file__).resolve().parents[1] | |
| def local(path): | |
| p=(ROOT/path).resolve() | |
| if not p.is_relative_to(ROOT):raise ValueError('Path outside release: '+path) | |
| return p | |
| manifest=json.loads((ROOT/'release_manifest.json').read_text()) | |
| for item in manifest['files']: | |
| p=local(item['path']);assert p.is_file(),item['path'] | |
| assert p.stat().st_size==item['bytes'],item['path'] | |
| with p.open('rb') as f: | |
| digest=hashlib.file_digest(f,'sha256').hexdigest() if hasattr(hashlib,'file_digest') else hashlib.sha256(f.read()).hexdigest() | |
| assert digest==item['sha256'],item['path'] | |
| record=json.loads((ROOT/'examples/baseball_swing.json').read_text()) | |
| assert record['split']=='case-study' | |
| assert record['timing']['frame_count']==52 and record['timing']['fps']==30 | |
| for path in record['artifacts'].values():assert local(path).is_file(),path | |
| with local(record['artifacts']['animated_fbx']).open('rb') as f:assert f.read(23)==b'Kaydara FBX Binary \x00\x1a\x00' | |
| class Links(HTMLParser): | |
| def __init__(self):super().__init__();self.paths=[];self.ids=[];self.fragments=[] | |
| def handle_starttag(self,tag,attrs): | |
| d=dict(attrs) | |
| if 'id' in d:self.ids.append(d['id']) | |
| for name in ['href','src','poster']: | |
| u=urlsplit(d.get(name,'')) | |
| if u.scheme or u.netloc:continue | |
| if u.path:self.paths.append(unquote(u.path)) | |
| elif u.fragment:self.fragments.append(u.fragment) | |
| p=Links();p.feed((ROOT/'whitepaper/index.html').read_text()) | |
| for path in p.paths:assert local('whitepaper/'+path).is_file(),path | |
| assert len(p.ids)==len(set(p.ids)) | |
| assert all(x in p.ids for x in p.fragments) | |
| print(f"Verified {len(manifest['files'])} release files, the FBX header, example record and local paper links.") | |
| print('Integrity check only; this does not execute reconstruction or model inference.') | |