"""Download only the official four-step, chunkwise Causal-Forcing student.""" from pathlib import Path from huggingface_hub import HfApi, hf_hub_download from scripts.causal_baselines_b200.common import ROOT, read, write, sha def main(): destination = ROOT / 'assets' receipt = destination / 'causal_forcing.json' if receipt.exists(): old = read(receipt) if Path(old['checkpoint']).is_file() and sha(old['checkpoint']) == old['sha256']: print('Official Causal-Forcing checkpoint already verified', flush=True) return api = HfApi() info = api.model_info('zhuhz22/Causal-Forcing', files_metadata=True) name = 'chunkwise/causal_forcing.pt' entry = next(x for x in info.siblings if x.rfilename == name) checkpoint = Path(hf_hub_download(info.id, name, revision=info.sha, local_dir=destination)) checksum = sha(checkpoint) assert entry.lfs is not None and entry.lfs.sha256 == checksum write(receipt, dict(repo_id=info.id, revision=info.sha, filename=name, checkpoint=str(checkpoint), bytes=checkpoint.stat().st_size, sha256=checksum, variant='official chunkwise Causal-Forcing, four steps, 81 output frames')) print(read(receipt), flush=True) if __name__ == '__main__': main()