Datasets:
File size: 1,575 Bytes
8fda96c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import json,hashlib,collections
from pathlib import Path
from datasets import load_dataset,Sequence,Image
from huggingface_hub import HfApi
from common import read_jsonl,write_json
root=Path('/home/ach18533cl/workspace/SceneBench');cfg=json.loads((root/'config.json').read_text());auth=json.loads(Path('/home/ach18533cl/.cache/scenebench-auth/credentials.json').read_text());info=HfApi(token=auth['hf']).repo_info(cfg['hf_repo'],repo_type='dataset');revision=info.sha
ds=load_dataset(cfg['hf_repo'],split='test',revision=revision,token=auth['hf']);ds=ds.cast_column('images',Sequence(Image(decode=False)))
rows=list(read_jsonl(root/'release/benchmark.jsonl'));assert len(ds)==len(rows);images=0
for r,x in zip(rows,ds):
for k in ['id','task','family','question','options','answer','answer_text','answer_index','video_id','frame_ids','episode_id']:assert r[k]==x[k],(r['id'],k)
assert len(x['images'])==len(r['images'])
for p,meta in zip(x['images'],r['image_metadata']):assert hashlib.sha256(p['bytes']).hexdigest()==meta['sha256'];images+=1
assert json.loads(x['marker_json'])==r['marker']
p=json.loads(x['provenance_json']);assert p['source_evidence']==r['source_evidence'] and p['query']==r['query']
report=dict(status='pass',repo=cfg['hf_repo'],private=info.private,revision=revision,rows=len(rows),embedded_image_instances=images,checks='All question/options/answer fields, frame order, markers, source evidence and every embedded image SHA256 match ABCI frozen release.')
write_json(root/'work/hf_readback_report.json',report);print(json.dumps(report),flush=True)
|