File size: 1,504 Bytes
7e7a152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Refresh source-integrity hashes and optionally bind a verified visual initializer."""
import argparse,hashlib,json
from pathlib import Path
R=Path(__file__).resolve().parent

def refresh(bind_visual=False):
 hvs=R/'training/hvs_visual_to_audio_v1/config.json'
 config=json.loads(hvs.read_text())
 if bind_visual:
  source=Path(config['source_checkpoint'])
  if not source.is_absolute():source=R/source
  done=json.loads((source.parent/'complete.json').read_text())
  assert done['full_parameter'] and not done['lora'] and not done['audio_encoder']
  h=hashlib.sha256()
  with source.open('rb') as f:
   for block in iter(lambda:f.read(8*1024*1024),b''):h.update(block)
  assert h.hexdigest()==done['checkpoint_sha256'],'Visual initializer hash mismatch'
  config['source_checkpoint_sha256']=h.hexdigest()
  hvs.write_text(json.dumps(config,indent=2)+'\n')
 path=R/'training/echoscout_no_sft_v1/config.json';spec=json.loads(path.read_text())
 spec['baseline_configs']={p:json.loads((hvs if p=='hvs_original' else R/'training/stereo_backbones_v1/config.json').read_text()) for p in spec['parents']}
 spec['source_sha256']={n:hashlib.sha256((R/n).read_bytes()).hexdigest() for n in spec['source_sha256']}
 path.write_text(json.dumps(spec,indent=2)+'\n')

if __name__=='__main__':
 parser=argparse.ArgumentParser();parser.add_argument('--bind-visual',action='store_true');args=parser.parse_args()
 refresh(args.bind_visual)
 print('Portable configurations and matched-ablation integrity hashes updated.')