File size: 642 Bytes
51bce91
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""Run inside a downloaded model repository, or pass its directory."""
import hashlib,json,sys
from pathlib import Path
root=Path(sys.argv[1] if len(sys.argv)>1 else '.')
manifest=json.loads((root/'FINAL_WEIGHT_MANIFEST.json').read_text())
for row in manifest['files']:
 p=root/row['repo_path'];assert p.is_file(),f'Missing: {p}'
 assert p.stat().st_size==row['bytes'],f'Size mismatch: {p}'
 h=hashlib.sha256()
 with p.open('rb') as f:
  for block in iter(lambda:f.read(8*1024*1024),b''):h.update(block)
 assert h.hexdigest()==row['sha256'],f'Hash mismatch: {p}'
 print('OK',row['repo_path'])
print('Verified',len(manifest['files']),'files')