File size: 3,146 Bytes
8fda96c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json,collections,shutil
from pathlib import Path
from common import read_jsonl,write_json
root=Path('/home/ach18533cl/workspace/SceneBench');rows=list(read_jsonl(root/'release/benchmark.jsonl'));tasks=sorted({r['task'] for r in rows})
def counter(rr,fn):return dict(collections.Counter(str(fn(r)) for r in rr))
bytask={}
for t in tasks:
 rr=[r for r in rows if r['task']==t]
 bytask[t]={'n':len(rr),'videos':counter(rr,lambda r:r['video_id']),'first_frame_phase':counter(rr,lambda r:r['source_evidence'][0]['phase']),'answer_classes':counter(rr,lambda r:r['answer_class']),'independent_label_segments_or_action_runs':len({r['episode_id'] for r in rr}),'input_frames':counter(rr,lambda r:len(r['images']))}
 if t.startswith('D'):bytask[t]['time_gaps_seconds']=counter(rr,lambda r:r['frame_ids'][1]-r['frame_ids'][0]);bytask[t]['changed']=counter(rr,lambda r:r['tags']['changed'])
conditional=[]
for t in tasks:
 for key in ['instrument','verb','target','tool']:
  rr=[r for r in rows if r['task']==t and key in r['tags']]
  for val in sorted({str(r['tags'][key]) for r in rr}):
   cc=collections.Counter(r['answer_class'] for r in rr if str(r['tags'][key])==val);n=sum(cc.values())
   if n>=8:conditional.append({'task':t,'condition':key,'value':val,'n':n,'answer_distribution':dict(cc),'largest_class_fraction':max(cc.values())/n})
report={'task_distribution':bytask,'conditional_answer_distributions':conditional,'interpretation':'Label support constrains balance. Conditional concentration is a shortcut diagnostic, not evidence of model cheating. No samples were edited in response to baseline outcomes. Episode IDs for ordinary tasks may be time buckets and must not be counted as expert clinical events.'}
write_json(root/'release/distribution_audit.json',report);shutil.copy(root/'release/distribution_audit.json',root/'huggingface/distribution_audit.json');shutil.copy(root/'audit_distribution.py',root/'huggingface/code/audit_distribution.py')
lines=['','## 冻结后的分布审计','', '下面统计每个问题首帧的 Phase_gt;动态题同时在 distribution_audit.json 记录两帧间隔和变化/稳定分布。编号 0 是 Preparation,1–6 为已列出的六个操作阶段。普通题不是按所有阶段强行等额抽样;PR01 精确按六阶段各 50 题,CVS 只在合格 Calot 内抽样。','', '| 题型 | phase 0 | phase 1 | phase 2 | phase 3 | phase 4 | phase 5 | phase 6 |','|---|---:|---:|---:|---:|---:|---:|']
for t,st in bytask.items():lines.append('| '+t+' | '+' | '.join(str(st['first_frame_phase'].get(str(p),0)) for p in range(7))+' |')
lines+=['','distribution_audit.json 还提供题型×视频、题型×答案、条件词×答案、动态时间间隔和事件/片段 ID 计数。高频动作与可见结构受真实手术过程限制,本版本没有通过伪造组合实现每个条件下严格均匀,也未声称消除了所有语言先验。']
for p in [root/'docs/Benchmark说明_20260922.md',root/'huggingface/docs/Benchmark说明_20260922.md']:p.write_text(p.read_text()+'\n'.join(lines)+'\n')
print(json.dumps({'tasks':len(bytask),'conditional_strata':len(conditional)}),flush=True)