EgoF0102 commited on
Commit
7735593
·
verified ·
1 Parent(s): 76e2d21

SceneBench v1: frozen source-derived test benchmark and verified artifacts

Browse files
FROZEN.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "benchmark_sha256": "260d6a03c822f6d80e0eb4b585924e3d1910e39f0503ded056bbb61132276bc6",
4
+ "items": 2230,
5
+ "created_utc": "2026-09-22T09:41:26.920140+00:00",
6
+ "curation_before_baseline": true
7
+ }
LICENSE ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
2
+ https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
3
+ Source images and annotations retain their respective original authors and attribution.
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+ task_categories:
4
+ - visual-question-answering
5
+ language:
6
+ - en
7
+ tags:
8
+ - surgery
9
+ - laparoscopic-cholecystectomy
10
+ - scene-graph
11
+ size_categories:
12
+ - 1K<n<10K
13
+ configs:
14
+ - config_name: default
15
+ data_files:
16
+ - split: test
17
+ path: data/test-*.parquet
18
+ ---
19
+ # SceneBench v1.0.0
20
+
21
+ 2230 source-derived multiple-choice questions across 28 task types and six families, generated anew from nine held-out CholecT45 videos. One test benchmark; no training or validation split is distributed.
22
+
23
+ | Family | Questions |
24
+ |---|---:|
25
+ | Perception | 334 |
26
+ | Relation | 480 |
27
+ | Composition | 506 |
28
+ | Procedure | 300 |
29
+ | CVS | 219 |
30
+ | Dynamic | 391 |
31
+
32
+ ## Loading
33
+
34
+ ```python
35
+ from datasets import load_dataset
36
+ ds = load_dataset("EgoF0102/SceneBench", split="test", token=True)
37
+ row = ds[0]
38
+ images = row["images"] # List of PIL images; one, or two in chronological order.
39
+ print(row["question"], row["options"], row["answer"])
40
+ ```
41
+
42
+ Image bytes are embedded in Parquet. Yellow box A / arrow A is already rendered for P01/P02. Do not pass answer fields, provenance, video IDs, timestamps or source graphs to a direct-VQA baseline. Options are presented in stored order. P03/V04 have 2 options, V01–V03 have 3, all others have 4. The answer letter is determined by answer_index. Each question has one source-derived answer.
43
+
44
+ ## Sources and split
45
+
46
+ Test videos: VID02, VID06, VID14, VID23, VID25, VID50, VID51, VID66, VID79. All other videos must remain outside this test split when constructing training data. Indices are zero-based 1 fps indices; original Cholec80 frame index is 25 times this index.
47
+
48
+ - [Cholec80 / EndoNet](https://github.com/CAMMA-public/Cholec80): phase and tool presence.
49
+ - [CholecT45 / Rendezvous](https://github.com/CAMMA-public/cholect45): images and instrument-verb-target annotations. Cite Nwoye et al., *Rendezvous: Attention Mechanisms for the Recognition of Surgical Action Triplets in Endoscopic Videos*, Medical Image Analysis, 2022.
50
+ - [SSG-VQA](https://arxiv.org/abs/2312.10251): supplied scene graphs, object categories, boxes and spatial relations; cite Yuan et al., *Advancing Surgical VQA with Scene Graph Knowledge*, 2023. See local source provenance for exact records.
51
+ - [Cholec80-CVS](https://www.nature.com/articles/s41597-023-02073-7): segmented CVS criterion scores. Follow the original paper and source repositories for full author attribution and citations.
52
+
53
+ ## Generation and quality
54
+
55
+ Queries are deterministic functions of source labels. Ambiguous action queries are rejected. Spatial directions use 430×240 bbox-center geometry, a 5% axis margin, and matching positive/inverse relation edges. Graph-detected tool categories are cross-checked against source tool-presence labels. Per-task answer/video balancing, spacing and image deduplication limit repetition; actual counts and distributions are in dataset_statistics.json. Source frames are reused at most twice, and Dynamic endpoints are exclusive to their one pair. Dynamic questions compare two endpoint states, not tracked physical instrument identities.
56
+
57
+ 101 of 2331 selected candidates were removed during visual screening; 18 anatomy arrow tips were adjusted within the source box. P01/P02/P04/C06 received screening of all selected items; C04/C05/CVS received answer-stratified screening. This was Codex visual screening, not expert surgical adjudication. The source scene graphs contain model-generated detections and can contain residual errors. **This release is source-consistent, not a claim of independently expert-verified gold for every image.** Review scope and exclusions are public in curation_report.json. No baseline predictions were used for curation.
58
+
59
+ ## CVS interpretation
60
+
61
+ Only Calot triangle dissection before the first clipping/cutting transition is eligible. Annotated intervals include both endpoints. Uncovered segments inside the valid domain default to (0,0,0); labels are not forward-filled. Conflicting overlapping scores are excluded. V01–V03 use the native 0/1/2 criterion scores; V04 follows the source rule total score >=5. This is a dataset convention, not independent clinical certification. Multiple spaced/deduplicated frames per interval are allowed.
62
+
63
+ V04 has only three positive frames, all from one event in VID66 (661–675 seconds). V03 score 2 has the same event concentration. V02 score 2 occurs in two VID51 intervals. Multiple frames do not create independent clinical events. Some V04 negatives are matched to VID66 and late Calot. Results for rare criteria must be interpreted at video/event level.
64
+
65
+ ## Evaluation
66
+
67
+ The baseline protocol uses `qwen/qwen3-vl-32b-instruct` through OpenRouter, temperature 0, one call per question, only exported images + question/options, returning a single option letter. It is a zero-shot base-Instruct direct-VQA baseline, without SFT/RL or predicted-graph conditioning. Results and a separate Chinese analysis document are added after complete evaluation. Total micro accuracy and descriptive family/task/class breakdowns refer to this same benchmark.
68
+
69
+ ## License and reproducibility
70
+
71
+ CC BY-NC-SA 4.0. Images and source-derived annotations retain source attribution, non-commercial restrictions and share-alike terms. See [the license](https://creativecommons.org/licenses/by-nc-sa/4.0/) and original source publications. Export processing adds markers, resizes longest edge to at most 1280 and encodes JPEG quality 95; no crop or flip.
72
+
73
+ Full Chinese task definitions, real examples, source mapping, sampling and limitations: [Benchmark说明](docs/Benchmark说明_20260922.md). Generator, fixed curation decisions and validator: code/. Credentials and raw unused source data are not included.
74
+
75
+ Frozen benchmark SHA256: `260d6a03c822f6d80e0eb4b585924e3d1910e39f0503ded056bbb61132276bc6`.
code/common.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json, pickle, hashlib, collections, random, itertools, math
2
+ from pathlib import Path
3
+ import numpy as np
4
+ import openpyxl
5
+
6
+ INSTRUMENTS=['grasper','bipolar','hook','scissors','clipper','irrigator']
7
+ TOOLS=INSTRUMENTS+['specimen_bag']
8
+ ANATOMIES=['gallbladder','liver','omentum','gut','cystic_plate']
9
+ VERBS=['grasp','retract','dissect','coagulate','clip','cut','aspirate','irrigate','pack']
10
+ GERUND={'grasp':'Grasping','retract':'Retracting','dissect':'Dissecting','coagulate':'Coagulating','clip':'Clipping','cut':'Cutting','aspirate':'Aspirating','irrigate':'Irrigating','pack':'Packing'}
11
+ PARTICIPLE={'grasp':'grasped','retract':'retracted','dissect':'dissected','coagulate':'coagulated','clip':'clipped','cut':'cut','aspirate':'aspirated','irrigate':'irrigated','pack':'packed'}
12
+ PHASES={0:'Preparation',1:'Calot triangle dissection',2:'Clipping and cutting',3:'Gallbladder dissection',4:'Gallbladder packaging',5:'Cleaning and coagulation',6:'Gallbladder retraction'}
13
+ QUADS=['Upper left','Upper right','Lower left','Lower right']
14
+ INV={'left':'right','right':'left','above':'below','below':'above'}
15
+ FAMILIES={'P':'Perception','R':'Relation','C':'Composition','PR':'Procedure','V':'CVS','D':'Dynamic'}
16
+ def display(x):return x.replace('_',' ')
17
+ def title(x):return display(x).capitalize()
18
+ def digest(x):return hashlib.sha256(json.dumps(x,sort_keys=True,separators=(',',':')).encode()).hexdigest()
19
+ def write_json(p,x):Path(p).parent.mkdir(parents=True,exist_ok=True);Path(p).write_text(json.dumps(x,ensure_ascii=False,indent=2))
20
+ def read_jsonl(p):
21
+ with open(p) as f:
22
+ for l in f:
23
+ if l.strip():yield json.loads(l)
24
+ def write_jsonl(p,rows):
25
+ Path(p).parent.mkdir(parents=True,exist_ok=True)
26
+ with open(p,'w') as f:
27
+ for r in rows:f.write(json.dumps(r,ensure_ascii=False,separators=(',',':'))+'\n')
28
+ def family(task):return FAMILIES[''.join(x for x in task if x.isalpha())]
29
+
30
+ class Sources:
31
+ def __init__(self,ori,videos):
32
+ self.ori=Path(ori);self.videos=videos;self.phase={};self.ivt={};self.graphs={};self.action_starts={};self.cvt={};self.counts=collections.Counter()
33
+ for fn in ['train/1fps_100_0.pickle','val/1fps.pickle','test/1fps.pickle']:
34
+ p=self.ori/' Cholec80_labels/labels'/fn
35
+ with p.open('rb') as f:d=pickle.load(f)
36
+ for key,rows in d.items():
37
+ v=int(key[5:])
38
+ if v in videos:
39
+ self.phase[v]=rows
40
+ assert all(int(r['Original_frame_id'])==i*25 for i,r in enumerate(rows)),('alignment',v)
41
+ vocab={int(a):tuple(b.split(',')) for line in (self.ori/'CholecT45/dict/triplet.txt').read_text().splitlines() for a,b in [line.split(':',1)]}
42
+ for v in videos:
43
+ self.ivt[v]={};starts={}
44
+ for line in (self.ori/f'CholecT45/triplet/VID{v:02d}.txt').read_text().splitlines():
45
+ row=list(map(int,line.split(',')));f=row[0];ts={vocab[i] for i,a in enumerate(row[1:]) if a}
46
+ for t in ts:
47
+ if t not in starts:starts[t]=f
48
+ self.action_starts[v,f,t]=starts[t]
49
+ starts={t:starts[t] for t in ts};self.ivt[v][f]=ts
50
+ for f in range(len(self.phase[v])):
51
+ p=self.ori/f'scene_graph/VID{v:02d}_{f}.json'
52
+ if p.exists():
53
+ try:self.graphs[v,f]=json.loads(p.read_text())['scenes'][0]
54
+ except (KeyError,IndexError,ValueError):self.counts['invalid_sg']+=1
55
+ self.cvs_rows=[]
56
+ ws=openpyxl.load_workbook(self.ori/'Cholec80_CVS/cholec80-CVS.xlsx',data_only=True).active
57
+ for i,row in enumerate(ws.values):
58
+ if not i or int(row[0]) not in videos:continue
59
+ r=dict(row=i+1,video=int(row[0]),start=int(row[2])*60+int(row[3]),end=int(row[4])*60+int(row[5]),scores=list(map(int,row[6:9])),total=int(row[9]),cv=int(row[1]))
60
+ assert sum(r['scores'])==r['total'] and int(r['total']>=5)==r['cv']
61
+ self.cvs_rows.append(r)
62
+ for v in videos:
63
+ first=next(i for i,r in enumerate(self.phase[v]) if r['Phase_gt']==2)
64
+ rs=[r for r in self.cvs_rows if r['video']==v and r['start']<=r['end']]
65
+ good={}
66
+ for f in range(first):
67
+ if self.phase[v][f]['Phase_gt']!=1:continue
68
+ rr=[r for r in rs if r['start']<=f<=r['end']];vals={tuple(r['scores']) for r in rr}
69
+ if len(vals)>1:self.counts['cvs_conflicting_seconds']+=1;continue
70
+ score=next(iter(vals)) if vals else (0,0,0)
71
+ good[f]=dict(scores=list(score),cv=int(sum(score)>=5),rows=[r['row'] for r in rr],source='explicit_interval' if rr else 'protocol_default_zero')
72
+ for k in range(4):
73
+ segments=[]
74
+ for f,r in good.items():
75
+ value=r['scores'][k] if k<3 else r['cv']
76
+ if segments and segments[-1]['end']==f-1 and segments[-1]['value']==value:segments[-1]['end']=f
77
+ else:segments.append(dict(start=f,end=f,value=value))
78
+ for seg in segments:
79
+ for f in range(seg['start'],seg['end']+1):
80
+ good[f][f'episode_{k}']=seg
81
+ self.cvt[v]=good
82
+ print('Source loaded',len(self.graphs),'graphs;',sum(len(x) for x in self.ivt.values()),'IVT frames',flush=True)
83
+ def image_path(self,v,f):return self.ori/f'CholecT45/data/VID{v:02d}/{f:06d}.png'
84
+ def tools(self,v,f):
85
+ t=self.phase[v][f]['Tool_gt']
86
+ return None if t is None else {TOOLS[i] for i,a in enumerate(t) if a}
87
+ def clean_objects(self,v,f):
88
+ g=self.graphs.get((v,f),{});out={}
89
+ for i,o in enumerate(g.get('objects',[])):
90
+ b=o.get('bbox');c=o.get('center')
91
+ if not b or not c or len(b)!=4:continue
92
+ x,y,X,Y=b
93
+ if not (0<=x<X<=430 and 0<=y<Y<=240):continue
94
+ if abs(c[0]-(x+X)/2)>0.01 or abs(c[1]-(y+Y)/2)>0.01:continue
95
+ w=X-x;h=Y-y
96
+ if o['type']=='instrument' and (w<15 or h<10 or w*h<450):continue
97
+ if o['type']=='anatomy' and (w<25 or h<18 or w*h<1000):continue
98
+ out[i]=o
99
+ return out
100
+ def unique(self,v,f):
101
+ objs=self.clean_objects(v,f);cnt=collections.Counter(o['component'] for o in self.graphs.get((v,f),{}).get('objects',[]))
102
+ return {o['component']:i for i,o in objs.items() if cnt[o['component']]==1}
103
+ def spatial(self,v,f,a,b,p,require_edge=True):
104
+ if a==b:return False
105
+ o=self.graphs[v,f]['objects'];axis=0 if p in ['left','right'] else 1
106
+ d=(o[a]['center'][axis]-o[b]['center'][axis])*(1 if p in ['right','below'] else -1)
107
+ if d<(.05*(430 if axis==0 else 240)):return False
108
+ if not require_edge:return True
109
+ r=self.graphs[v,f]['relationships'];return a in r.get(p,[[]]*len(o))[b] and b in r.get(INV[p],[[]]*len(o))[a]
110
+ def definite(self,v,f,a,b,p):
111
+ if a==b:return True
112
+ o=self.graphs[v,f]['objects'];axis=0 if p in ['left','right'] else 1
113
+ return abs(o[a]['center'][axis]-o[b]['center'][axis])>=.05*(430 if axis==0 else 240)
114
+ def consistent(self,v,f,a,b,p):
115
+ return self.definite(v,f,a,b,p) and (not self.spatial(v,f,a,b,p,False) or self.spatial(v,f,a,b,p,True))
116
+ def quadrant(self,v,f,a,b=None):
117
+ o=self.graphs[v,f]['objects'];x,y=o[a]['center'];X,Y=(215,120) if b is None else o[b]['center']
118
+ if abs(x-X)<21.5 or abs(y-Y)<12:return None
119
+ p='left' if x<X else 'right';q='above' if y<Y else 'below'
120
+ if b is not None and not (self.spatial(v,f,a,b,p) and self.spatial(v,f,a,b,q)):return None
121
+ return ('Upper' if y<Y else 'Lower')+(' left' if x<X else ' right')
122
+ def action_edge(self,v,f,inst,verb,target):
123
+ u=self.unique(v,f)
124
+ if inst not in u or target not in u:return False
125
+ g=self.graphs[v,f];return u[target] in g['relationships'].get(verb,[[]]*len(g['objects']))[u[inst]]
126
+ def source_evidence(self,v,frames):
127
+ out=[]
128
+ for f in frames:
129
+ r=self.phase[v][f];g=self.graphs.get((v,f))
130
+ out.append(dict(video=f'VID{v:02d}',frame_1fps=f,original_frame_id=int(r['Original_frame_id']),phase=int(r['Phase_gt']),tools=None if r['Tool_gt'] is None else list(map(int,r['Tool_gt'])),ivt=sorted(self.ivt[v].get(f,set())),scene_graph=g,source_image=str(self.image_path(v,f))))
131
+ return out
code/config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "seed": 20260922,
4
+ "test_videos": [2, 6, 14, 23, 25, 50, 51, 66, 79],
5
+ "target_counts": {"P01":80,"P02":80,"P03":80,"P04":80,"P05":80,"R01":80,"R02":80,"R03":80,"R04":80,"R05":80,"R06":80,"C01":80,"C02":80,"C03":80,"C04":80,"C05":80,"C06":80,"C07":80,"PR01":300,"V01":90,"V02":60,"V03":60,"V04":10,"D01":80,"D02":80,"D03":80,"D04":80,"D05":80},
6
+ "cvs_answer_targets":{"V01":{"0":32,"1":32,"2":26},"V02":{"0":27,"1":27,"2":6},"V03":{"0":28,"1":28,"2":4},"V04":{"No":6,"Yes":4}},
7
+ "spatial_margin":0.05,
8
+ "default_min_spacing_seconds":10,
9
+ "cvs_min_spacing_seconds":3,
10
+ "max_questions_per_source_frame":2,
11
+ "max_export_image_dimension":1280,
12
+ "model":"qwen/qwen3-vl-32b-instruct",
13
+ "evaluation_protocol":"zero_shot_direct_vqa",
14
+ "hf_repo":"EgoF0102/SceneBench",
15
+ "hf_private":true
16
+ }
code/curate.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json,random,collections,hashlib,shutil
2
+ from pathlib import Path
3
+ from common import *
4
+ from select_render import Selector,render,contacts
5
+
6
+ root=Path('/home/ach18533cl/workspace/SceneBench')
7
+ cfg=json.loads((root/'config.json').read_text());review=json.loads((root/'curation.json').read_text())
8
+ src=Sources('/home/ach18533cl/workspace/ori_data',cfg['test_videos'])
9
+ original=root/'work/precuration_benchmark.jsonl'
10
+ if not original.exists():shutil.copy(root/'release/benchmark.jsonl',original)
11
+ allrows=list(read_jsonl(original));rows=[r for r in allrows if r['id'] not in review['drop']]
12
+ candidates={r['candidate_id']:r for r in read_jsonl(root/'work/selected_candidates.jsonl')}
13
+ sel=Selector(src,root,cfg)
14
+ for r in rows:sel.accept(candidates[r['candidate_id']])
15
+ # Replace three cross-video V04 negatives with same-video late-Calot negatives.
16
+ pool=[c for c in read_jsonl(root/'work/candidates/V04.jsonl') if c['video']==66 and c['answer']=='No' and 520<=c['frames'][0]<661]
17
+ pool.sort(key=lambda c:(-sum(c['query']['scores']),abs(c['frames'][0]-640)))
18
+ replace_ids=['SCB-V04-0001','SCB-V04-0002','SCB-V04-0004'];replacement_log=[]
19
+ for qid in replace_ids:
20
+ c=next((c for c in pool if sel.allowed(c)),None)
21
+ if c is None:break
22
+ sel.accept(c);r=next(r for r in rows if r['id']==qid);old=r['candidate_id']
23
+ r.update(question=c['question'],options=c['choices'],answer_text=c['answer'],answer_class=c['answer_class'],video_id='VID66',frame_ids=c['frames'],source_frame_ids=[f*25 for f in c['frames']],episode_id=c['episode'],query=c['query'],tags=c['tags'],candidate_id=c['candidate_id'],source_evidence=src.source_evidence(66,c['frames']))
24
+ r['images']=[f'images/v66_{c["frames"][0]:06d}.jpg'];r['image_metadata']=[render(c,src.image_path(66,c['frames'][0]),root/'release'/r['images'][0],cfg)]
25
+ replacement_log.append(dict(id=qid,old_candidate_id=old,new_candidate_id=c['candidate_id'],frame=c['frames'][0],reason='Same-video, late-Calot negative control'))
26
+ for r in rows:
27
+ if r['id'] in review['point_patches']:
28
+ pt=review['point_patches'][r['id']];b=r['marker']['bbox'];assert b[0]<=pt[0]<=b[2] and b[1]<=pt[1]<=b[3],r['id']
29
+ r['marker']['point']=pt;r['marker']['placement']='visually_adjusted_within_source_bbox'
30
+ r['image_metadata']=[render(r,src.image_path(int(r['video_id'][3:]),r['frame_ids'][0]),root/'release'/r['images'][0],cfg)]
31
+ if r.get('marker'):r['marker']['review_required']=False
32
+ r['quality_status']='source_consistency_checked; all-selected-items visual screening' if r['task'] in review['fully_reviewed_tasks'] else 'source_consistency_checked; task-level stratified visual screening' if r['task'] in review['stratified_review_tasks'] else 'source_consistency_and_automated_image_quality_checked'
33
+ rng=random.Random(cfg['seed']+3);bytask=collections.defaultdict(list)
34
+ for r in rows:bytask[r['task']].append(r)
35
+ for task,rr in bytask.items():
36
+ for i,r in enumerate(rr):
37
+ others=[x for x in r['options'] if x!=r['answer_text']];rng.shuffle(others);pos=i%len(r['options']);others.insert(pos,r['answer_text']);r.update(options=others,answer='ABCD'[pos],answer_index=pos)
38
+ write_jsonl(root/'release/benchmark.jsonl',rows)
39
+ write_json(root/'release/curation_report.json',dict(initial=len(allrows),final=len(rows),dropped=len(review['drop']),point_corrections=len(review['point_patches']),review=review,replacements=replacement_log,tasks={t:len(v) for t,v in bytask.items()},families=dict(collections.Counter(r['family'] for r in rows)),scope='Source-derived reference answers; visual screening by Codex is not expert medical validation. No baseline-model outputs were used to select or edit questions.'))
40
+ used={p for r in rows for p in r['images']}
41
+ for p in (root/'release/images').glob('*.jpg'):
42
+ if str(p.relative_to(root/'release')) not in used:p.unlink()
43
+ contacts(root,rows)
44
+ print(json.dumps(dict(final=len(rows),replacements=replacement_log,tasks={t:len(v) for t,v in bytask.items()})),flush=True)
code/curation.json ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "reviewer": "Codex visual audit; not expert medical adjudication",
3
+ "drop": {
4
+ "SCB-P01-0014": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
5
+ "SCB-P01-0026": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
6
+ "SCB-P01-0034": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
7
+ "SCB-P01-0039": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
8
+ "SCB-P01-0042": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
9
+ "SCB-P01-0045": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
10
+ "SCB-P01-0052": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
11
+ "SCB-P01-0063": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
12
+ "SCB-P01-0065": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
13
+ "SCB-P01-0071": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
14
+ "SCB-P01-0077": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
15
+ "SCB-P02-0003": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
16
+ "SCB-P02-0004": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
17
+ "SCB-P02-0007": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
18
+ "SCB-P02-0009": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
19
+ "SCB-P02-0010": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
20
+ "SCB-P02-0012": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
21
+ "SCB-P02-0014": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
22
+ "SCB-P02-0016": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
23
+ "SCB-P02-0018": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
24
+ "SCB-P02-0023": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
25
+ "SCB-P02-0024": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
26
+ "SCB-P02-0026": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
27
+ "SCB-P02-0028": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
28
+ "SCB-P02-0030": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
29
+ "SCB-P02-0033": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
30
+ "SCB-P02-0034": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
31
+ "SCB-P02-0036": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
32
+ "SCB-P02-0037": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
33
+ "SCB-P02-0039": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
34
+ "SCB-P02-0041": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
35
+ "SCB-P02-0046": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
36
+ "SCB-P02-0050": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
37
+ "SCB-P02-0053": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
38
+ "SCB-P02-0058": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
39
+ "SCB-P02-0060": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
40
+ "SCB-P02-0063": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
41
+ "SCB-P02-0065": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
42
+ "SCB-P02-0070": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
43
+ "SCB-P02-0071": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
44
+ "SCB-P02-0072": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
45
+ "SCB-P02-0076": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
46
+ "SCB-P02-0077": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
47
+ "SCB-P04-0003": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
48
+ "SCB-P04-0005": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
49
+ "SCB-P04-0009": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
50
+ "SCB-P04-0024": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
51
+ "SCB-P04-0028": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
52
+ "SCB-P04-0031": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
53
+ "SCB-P04-0034": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
54
+ "SCB-P04-0036": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
55
+ "SCB-P04-0038": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
56
+ "SCB-P04-0040": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
57
+ "SCB-P04-0043": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
58
+ "SCB-P04-0047": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
59
+ "SCB-P04-0048": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
60
+ "SCB-P04-0055": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
61
+ "SCB-P04-0056": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
62
+ "SCB-P04-0061": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
63
+ "SCB-P04-0063": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
64
+ "SCB-P04-0064": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
65
+ "SCB-P04-0067": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
66
+ "SCB-P04-0068": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
67
+ "SCB-P04-0074": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
68
+ "SCB-P04-0077": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
69
+ "SCB-P04-0080": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
70
+ "SCB-C04-0004": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
71
+ "SCB-C04-0008": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
72
+ "SCB-C04-0012": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
73
+ "SCB-C04-0013": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
74
+ "SCB-C04-0023": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
75
+ "SCB-C06-0002": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
76
+ "SCB-C06-0005": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
77
+ "SCB-C06-0008": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
78
+ "SCB-C06-0010": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
79
+ "SCB-C06-0016": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
80
+ "SCB-C06-0019": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
81
+ "SCB-C06-0021": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
82
+ "SCB-C06-0024": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
83
+ "SCB-C06-0029": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
84
+ "SCB-C06-0031": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
85
+ "SCB-C06-0033": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
86
+ "SCB-C06-0035": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
87
+ "SCB-C06-0037": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
88
+ "SCB-C06-0038": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
89
+ "SCB-C06-0040": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
90
+ "SCB-C06-0041": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
91
+ "SCB-C06-0043": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
92
+ "SCB-C06-0044": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
93
+ "SCB-C06-0045": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
94
+ "SCB-C06-0046": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
95
+ "SCB-C06-0047": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
96
+ "SCB-C06-0054": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
97
+ "SCB-C06-0056": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
98
+ "SCB-C06-0058": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
99
+ "SCB-C06-0059": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
100
+ "SCB-C06-0063": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
101
+ "SCB-C06-0066": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
102
+ "SCB-C06-0067": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
103
+ "SCB-C06-0075": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
104
+ "SCB-C06-0078": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference."
105
+ },
106
+ "point_patches": {
107
+ "SCB-P02-0002": [
108
+ 135,
109
+ 50
110
+ ],
111
+ "SCB-P02-0013": [
112
+ 165,
113
+ 136
114
+ ],
115
+ "SCB-P02-0015": [
116
+ 110,
117
+ 175
118
+ ],
119
+ "SCB-P02-0020": [
120
+ 120,
121
+ 150
122
+ ],
123
+ "SCB-P02-0029": [
124
+ 345,
125
+ 125
126
+ ],
127
+ "SCB-P02-0031": [
128
+ 145,
129
+ 115
130
+ ],
131
+ "SCB-P02-0044": [
132
+ 165,
133
+ 25
134
+ ],
135
+ "SCB-P02-0048": [
136
+ 340,
137
+ 70
138
+ ],
139
+ "SCB-P02-0051": [
140
+ 240,
141
+ 110
142
+ ],
143
+ "SCB-P02-0056": [
144
+ 335,
145
+ 190
146
+ ],
147
+ "SCB-P02-0059": [
148
+ 325,
149
+ 160
150
+ ],
151
+ "SCB-P02-0064": [
152
+ 150,
153
+ 85
154
+ ],
155
+ "SCB-P02-0066": [
156
+ 310,
157
+ 175
158
+ ],
159
+ "SCB-P02-0067": [
160
+ 135,
161
+ 23
162
+ ],
163
+ "SCB-P02-0069": [
164
+ 195,
165
+ 75
166
+ ],
167
+ "SCB-P02-0074": [
168
+ 230,
169
+ 60
170
+ ],
171
+ "SCB-P02-0080": [
172
+ 151,
173
+ 58
174
+ ],
175
+ "SCB-P02-0075": [
176
+ 185,
177
+ 175
178
+ ]
179
+ },
180
+ "fully_reviewed_tasks": [
181
+ "P01",
182
+ "P02",
183
+ "P04",
184
+ "C06"
185
+ ],
186
+ "notes": "No model correctness or answer text used for curation. Final P02 marker correction completed before official baseline; three P01 API-format smoke checks are archived separately and excluded.",
187
+ "stratified_review_tasks": [
188
+ "C04",
189
+ "C05",
190
+ "V01",
191
+ "V02",
192
+ "V03",
193
+ "V04"
194
+ ]
195
+ }
code/evaluate_openrouter.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Resumable, image-only baseline. Credentials never enter the dataset or logs."""
2
+ import argparse,asyncio,base64,json,time,random,re,hashlib,collections,os
3
+ from pathlib import Path
4
+ import httpx
5
+ from common import read_jsonl,write_json
6
+
7
+ SYSTEM='You are answering a multiple-choice question about laparoscopic cholecystectomy images. Use the provided image or images. For spatial questions, left/right/above/below refer to bounding-box centers in image coordinates; image y increases downward. For CVS, use the Cholec80-CVS scoring convention: each of the three criteria has score 0, 1, or 2, and overall CVS is achieved when their sum is at least 5. Return only the single uppercase letter of the correct option. Do not include an explanation.'
8
+
9
+ def parse_answer(content,n):
10
+ if not isinstance(content,str):return None
11
+ s=content.strip()
12
+ m=re.fullmatch(r'[\s*`]*(?:\(?)([A-D])(?:\)?)[.\s*`]*',s)
13
+ if not m:m=re.fullmatch(r'(?:Answer|Final answer|Option)\s*[::]?\s*\(?([A-D])\)?[.\s]*',s,re.I)
14
+ return m.group(1).upper() if m and ord(m.group(1).upper())-65<n else None
15
+
16
+ def payload(item,release,model):
17
+ content=[]
18
+ for i,rel in enumerate(item['images']):
19
+ content.append({'type':'text','text':f'Frame {i+1}:' if len(item['images'])>1 else 'Image:'})
20
+ data=base64.b64encode((release/rel).read_bytes()).decode('ascii')
21
+ content.append({'type':'image_url','image_url':{'url':'data:image/jpeg;base64,'+data,'detail':'high'}})
22
+ text=item['question']+'\n'+'\n'.join(f'{chr(65+i)}. {o}' for i,o in enumerate(item['options']))+'\nReturn only the answer letter.'
23
+ content.append({'type':'text','text':text})
24
+ return {'model':model,'messages':[{'role':'system','content':SYSTEM},{'role':'user','content':content}],'temperature':0,'max_tokens':64,'seed':20260922,'stream':False}
25
+
26
+ async def run(args):
27
+ root=Path(args.root);release=root/'release';cfg=json.loads((root/'config.json').read_text());credentials=json.loads(Path(args.credentials).read_text());model=cfg['model'];items=list(read_jsonl(release/'benchmark.jsonl'))
28
+ assert (release/'FROZEN.json').exists(),'Freeze and validate benchmark before evaluating'
29
+ frozen=json.loads((release/'FROZEN.json').read_text());assert hashlib.sha256((release/'benchmark.jsonl').read_bytes()).hexdigest()==frozen['benchmark_sha256']
30
+ out=root/'evaluation';out.mkdir(exist_ok=True);path=out/'predictions.jsonl';done={r['id']:r for r in read_jsonl(path)} if path.exists() else {};todo=[r for r in items if r['id'] not in done or args.retry_errors and done[r['id']].get('status')!='ok']
31
+ if args.limit:todo=todo[:args.limit]
32
+ protocol=dict(model=model,benchmark_sha256=frozen['benchmark_sha256'],system_prompt=SYSTEM,temperature=0,max_tokens=64,seed=20260922,input='exported benchmark images + question + options only; no source graphs, GT, video IDs or timestamps',calls_per_question=1,retries='HTTP transport/429/5xx only, at most 5 attempts',parser='strict option letter, optionally prefixed by Answer/Final answer/Option',started_unix=time.time())
33
+ write_json(out/'protocol.json',protocol);sem=asyncio.Semaphore(args.concurrency);lock=asyncio.Lock();start=time.time();n=0
34
+ async with httpx.AsyncClient(timeout=httpx.Timeout(180,connect=30),limits=httpx.Limits(max_connections=args.concurrency,max_keepalive_connections=args.concurrency),headers={'Authorization':'Bearer '+credentials['openrouter'],'Content-Type':'application/json','X-Title':'SceneBench zero-shot evaluation'}) as client:
35
+ async def one(item):
36
+ nonlocal n
37
+ async with sem:
38
+ body=payload(item,release,model);t0=time.time();result=None;error=None
39
+ for attempt in range(5):
40
+ try:
41
+ response=await client.post('https://openrouter.ai/api/v1/chat/completions',json=body)
42
+ if response.status_code in [429,500,502,503,504]:
43
+ error=f'HTTP {response.status_code}'
44
+ if attempt<4:await asyncio.sleep(min(30,2**attempt+random.random()));continue
45
+ if response.status_code!=200:
46
+ error=f'HTTP {response.status_code}: '+response.text[:600];break
47
+ result=response.json()
48
+ if result.get('error'):error=str(result['error'])[:600];result=None
49
+ break
50
+ except (httpx.TimeoutException,httpx.TransportError) as ex:
51
+ error=type(ex).__name__
52
+ if attempt<4:await asyncio.sleep(min(30,2**attempt+random.random()))
53
+ record={'id':item['id'],'task':item['task'],'family':item['family'],'video_id':item['video_id'],'gold':item['answer'],'gold_text':item['answer_text'],'latency_s':time.time()-t0,'attempts':attempt+1,'model_requested':model,'timestamp_unix':time.time()}
54
+ if result:
55
+ choice=(result.get('choices') or [{}])[0];msg=choice.get('message') or {};content=msg.get('content','');pred=parse_answer(content,len(item['options']))
56
+ record.update(status='ok',prediction=pred,correct=pred==item['answer'],content=content,finish_reason=choice.get('finish_reason'),response_id=result.get('id'),model_returned=result.get('model'),provider=result.get('provider'),usage=result.get('usage',{}))
57
+ else:record.update(status='api_error',prediction=None,correct=False,error=error)
58
+ async with lock:
59
+ with path.open('a') as f:f.write(json.dumps(record,ensure_ascii=False)+'\n')
60
+ done[item['id']]=record;n+=1
61
+ if n%25==0 or n==len(todo):
62
+ rr=[done[x['id']] for x in items if x['id'] in done];progress={'completed':len(rr),'total':len(items),'ok':sum(r['status']=='ok' for r in rr),'correct':sum(r['correct'] for r in rr),'elapsed_s':round(time.time()-start,1)};write_json(out/'progress.json',progress);print(json.dumps(progress),flush=True)
63
+ await asyncio.gather(*(one(r) for r in todo))
64
+ write_json(out/'completion.json',{'completed':sum(x['id'] in done for x in items),'total':len(items),'finished_unix':time.time()})
65
+
66
+ def main():
67
+ p=argparse.ArgumentParser();p.add_argument('--root',default='/home/ach18533cl/workspace/SceneBench');p.add_argument('--credentials',default='/home/ach18533cl/.cache/scenebench-auth/credentials.json');p.add_argument('--concurrency',type=int,default=8);p.add_argument('--limit',type=int);p.add_argument('--retry-errors',action='store_true');a=p.parse_args();asyncio.run(run(a))
68
+ if __name__=='__main__':main()
code/generate.py ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse, random, itertools, collections, json, math
2
+ from pathlib import Path
3
+ from common import *
4
+
5
+ CVS_OPTIONS=[
6
+ ['0 — Two separate connecting structures cannot be established.','1 — Two structures are partly distinguishable, but overlap or limited clarity prevents a clear assessment.','2 — Two connecting structures are clearly distinguishable.'],
7
+ ['0 — The cystic plate is not visible or requires further dissection.','1 — It is visible, but exposure, overlap, or viewing angle limits the assessment.','2 — It is clearly exposed to approximately the lower third of the gallbladder.'],
8
+ ['0 — Tissue or technical limitations prevent assessment of the triangle and its structures.','1 — The triangle is only partly clear or its view remains limited.','2 — The triangle is fully cleared and its structures are clearly visible.'],['No','Yes']]
9
+ CVS_QUESTIONS=['How clearly are exactly two structures seen connecting to the gallbladder?','How clearly is the cystic plate exposed at the lower third of the gallbladder?','How clearly has the hepatocystic triangle been cleared to reveal its structures?','Is the critical view of safety (CVS) achieved in this image?']
10
+
11
+ class Generator:
12
+ def __init__(self,s,config):
13
+ self.s=s;self.cfg=config;self.rng=random.Random(config['seed']);self.pool=collections.defaultdict(list);self.seen=set();self.reject=collections.Counter()
14
+ self.all_targets=sorted({t[2] for d in s.ivt.values() for ts in d.values() for t in ts if t[2]!='null_target'})
15
+ self.inst_verbs={i:sorted({t[1] for d in s.ivt.values() for ts in d.values() for t in ts if t[0]==i and t[1]!='null_verb'}) for i in INSTRUMENTS}
16
+ def opts(self,answer,universe):
17
+ neg=[x for x in universe if x!=answer]
18
+ return [answer]+self.rng.sample(neg,3) if len(neg)>=3 else None
19
+ def add(self,task,v,frames,q,choices,answer,query,answer_class=None,episode=None,marker=None,tags=None):
20
+ if not choices or answer not in choices or len(set(choices))!=len(choices):return
21
+ if isinstance(frames,int):frames=[frames]
22
+ ident=digest([task,v,frames,query])[:20]
23
+ if ident in self.seen:return
24
+ self.seen.add(ident)
25
+ self.pool[task].append(dict(candidate_id=ident,task=task,family=family(task),video=v,frames=frames,question=q,choices=choices,answer=answer,answer_class=str(answer_class if answer_class is not None else answer),query=query,episode=episode or f'{v}:{task}:{frames[0]//30}',marker=marker,tags=tags or {}))
26
+ def run_episode(self,v,f,ts):return '|'.join(f'{v}:{"/".join(t)}:{self.s.action_starts.get((v,f,t),f)}' for t in sorted(ts))
27
+ def frame(self,v,f):
28
+ s=self.s;g=s.graphs.get((v,f));phase=int(s.phase[v][f]['Phase_gt']);raw=s.ivt[v].get(f,set());ts={t for t in raw if t[1]!='null_verb' and t[2]!='null_target'}
29
+ # Current-phase task covers complete phase inventory; exclude phase boundaries by 3 s.
30
+ if phase and f>=3 and f+3<len(s.phase[v]) and all(int(s.phase[v][k]['Phase_gt'])==phase for k in range(f-3,f+4)):
31
+ ans=PHASES[phase];self.add('PR01',v,f,'Which surgical phase is shown in this image?',self.opts(ans,[PHASES[i] for i in range(1,7)]),ans,{'op':'phase','phase':phase},phase)
32
+ if not g:return
33
+ objs=s.clean_objects(v,f);u=s.unique(v,f);present=s.tools(v,f)
34
+ if present is None:return
35
+ # Require graph detections and expert category presence to agree for tool queries.
36
+ toolids=[i for i,o in objs.items() if o['type']=='instrument' and o['component'] in INSTRUMENTS and o['component'] in present]
37
+ rawtoolids=[i for i,o in enumerate(g['objects']) if o['type']=='instrument' and o['component'] in INSTRUMENTS]
38
+ complete_tools=set(rawtoolids)==set(toolids) and {g['objects'][i]['component'] for i in toolids}==(present&set(INSTRUMENTS))
39
+ for i in toolids:
40
+ o=objs[i];a=o['component'];ans=title(a)
41
+ self.add('P01',v,f,'What type of instrument is indicated by box A?',self.opts(ans,[title(t) for t in INSTRUMENTS]),ans,{'op':'object_identity','id':i,'component':a},a,marker={'kind':'box','object_id':i,'bbox':o['bbox'],'label':'A'})
42
+ for a in ANATOMIES:
43
+ if a not in u:continue
44
+ i=u[a];o=objs[i];b=o['bbox'];point=o['center']
45
+ # Marker placement remains a visual-review gate, not automatic anatomy truth.
46
+ ans=title(a)
47
+ self.add('P02',v,f,'Which anatomical structure is indicated by arrow A?',self.opts(ans,[title(t) for t in ANATOMIES]),ans,{'op':'object_identity','id':i,'component':a},a,marker={'kind':'arrow','object_id':i,'bbox':b,'point':point,'label':'A','review_required':True})
48
+ # Tool absence is defined by original Tool_gt, not missing SG detections.
49
+ for a in INSTRUMENTS:
50
+ val=a in present
51
+ if val and a not in {objs[i]['component'] for i in toolids}:continue
52
+ if not val and any(o['component']==a for o in g['objects']):continue
53
+ self.add('P03',v,f,f'Is a {display(a)} visible in this image?',['Yes','No'],'Yes' if val else 'No',{'op':'tool_presence','tool':a},'Yes' if val else 'No',tags={'tool':a})
54
+ if complete_tools:
55
+ for a in INSTRUMENTS:
56
+ ids=[i for i in toolids if objs[i]['component']==a];n=len(ids)
57
+ if n>3:continue
58
+ # Duplicate overlapping detections are not counted as separate tools.
59
+ bad=False
60
+ for i,j in itertools.combinations(ids,2):
61
+ b=objs[i]['bbox'];c=objs[j]['bbox'];inter=max(0,min(b[2],c[2])-max(b[0],c[0]))*max(0,min(b[3],c[3])-max(b[1],c[1]));union=(b[2]-b[0])*(b[3]-b[1])+(c[2]-c[0])*(c[3]-c[1])-inter
62
+ if union and inter/union>.5:bad=True
63
+ if not bad:self.add('P04',v,f,f'How many separate {display(a)} instruments are visible?',['0','1','2','3'],str(n),{'op':'count_tools','tool':a,'ids':ids},n,tags={'tool':a})
64
+ for a in INSTRUMENTS:
65
+ if a not in u or u[a] not in toolids:continue
66
+ ans=s.quadrant(v,f,u[a])
67
+ if ans:self.add('P05',v,f,f'In which image quadrant is the center of the {display(a)} bounding box?',QUADS,ans,{'op':'absolute_quadrant','id':u[a]},ans,tags={'object':a})
68
+ # IVT three-way querying, with full matching answer-set uniqueness.
69
+ for inst,verb,target in sorted(ts):
70
+ if inst not in present or inst not in u or u[inst] not in toolids:continue
71
+ ep=self.run_episode(v,f,[(inst,verb,target)])
72
+ aa={t[1] for t in ts if t[0]==inst and t[2]==target}
73
+ if len(aa)==1:
74
+ ans=GERUND[verb];self.add('R01',v,f,f'What action is the {display(inst)} performing on the {display(target)}?',self.opts(ans,[GERUND[t] for t in VERBS]),ans,{'op':'ivt_verb','instrument':inst,'target':target},verb,ep,tags={'instrument':inst,'verb':verb,'target':target})
75
+ aa={t[0] for t in ts if t[1]==verb and t[2]==target}
76
+ if len(aa)==1:
77
+ ans=title(inst);self.add('R02',v,f,f'Which instrument is {GERUND[verb].lower()} the {display(target)}?',self.opts(ans,[title(t) for t in INSTRUMENTS]),ans,{'op':'ivt_instrument','verb':verb,'target':target},inst,ep,tags={'verb':verb,'target':target})
78
+ aa={t[2] for t in ts if t[0]==inst and t[1]==verb}
79
+ if len(aa)==1:
80
+ ans=title(target);self.add('R03',v,f,f'Which target is the {display(inst)} {GERUND[verb].lower()}?',self.opts(ans,[title(t) for t in self.all_targets]),ans,{'op':'ivt_target','instrument':inst,'verb':verb},target,ep,tags={'instrument':inst,'verb':verb})
81
+ # Quadrants are mutually exclusive; every axis is supported by both directed arrays.
82
+ pairs=list(itertools.permutations([a for a in u if a in ANATOMIES or a in INSTRUMENTS],2));self.rng.shuffle(pairs)
83
+ emitted=collections.Counter()
84
+ for a,b in pairs:
85
+ ia,ib=u[a],u[b];A=a in INSTRUMENTS;B=b in INSTRUMENTS
86
+ if A and ia not in toolids or B and ib not in toolids:continue
87
+ task='R06' if A and B else 'R05' if A and not B else 'R04' if not A and not B else None
88
+ if not task or emitted[task]>=2:continue
89
+ ans=s.quadrant(v,f,ia,ib)
90
+ if ans:
91
+ self.add(task,v,f,f'Where is the center of the {display(a)} bounding box relative to the center of the {display(b)} bounding box?',QUADS,ans,{'op':'relative_quadrant','subject':ia,'reference':ib},ans,tags={'subject':a,'reference':b});emitted[task]+=1
92
+ if phase==0:return
93
+ facts=[t for t in sorted(ts) if t[0] in u and t[2] in u and u[t[0]] in toolids and s.action_edge(v,f,*t)]
94
+ unique_facts=[t for t in facts if len({x[2] for x in ts if x[:2]==t[:2]})==1]
95
+ # Two independent actions -> ordered target pair, including partial-match distractors.
96
+ for x,y in itertools.combinations(unique_facts,2):
97
+ if x[0]==y[0]:continue
98
+ a,b=x[2],y[2];a2=self.rng.choice([t for t in ANATOMIES if t!=a]);b2=self.rng.choice([t for t in ANATOMIES if t!=b]);fmt=lambda p,q:f'({title(p)}, {title(q)})'
99
+ ans=fmt(a,b);opts=[ans,fmt(a2,b),fmt(a,b2),fmt(a2,b2)]
100
+ self.add('C01',v,f,f'Which ordered pair gives the structure {PARTICIPLE[x[1]]} by the {display(x[0])} first and the structure {PARTICIPLE[y[1]]} by the {display(y[0])} second?',opts,ans,{'op':'ordered_action_targets','queries':[list(x[:2]),list(y[:2])]},f'{a}|{b}',self.run_episode(v,f,[x,y]),tags={'ivts':[x,y]});break
101
+ refs=[a for a in u if a in ANATOMIES];self.rng.shuffle(refs)
102
+ # Spatially identify one tool, then follow its unique target.
103
+ for ref in refs:
104
+ for p in self.rng.sample(list(INV),4):
105
+ if len(toolids)<2 or any(not s.consistent(v,f,i,u[ref],p) for i in toolids):continue
106
+ ids=[i for i in toolids if s.spatial(v,f,i,u[ref],p)]
107
+ if len(ids)!=1:continue
108
+ inst=objs[ids[0]]['component'];targets={t[2] for t in facts if t[0]==inst}
109
+ if len(targets)!=1 or targets!={t[2] for t in ts if t[0]==inst}:continue
110
+ target=next(iter(targets));ans=title(target)
111
+ self.add('C02',v,f,f'Which structure is being acted on by the instrument whose bounding-box center is {self.phrase(p)} the {display(ref)} center?',self.opts(ans,[title(t) for t in ANATOMIES]),ans,{'op':'spatial_tool_target','reference':u[ref],'predicate':p},target,tags={'instrument':inst,'reference':ref});break
112
+ else:continue
113
+ break
114
+ for inst,verb,target in unique_facts:
115
+ for ref in refs:
116
+ if ref==target:continue
117
+ ans=s.quadrant(v,f,u[target],u[ref])
118
+ if ans:
119
+ self.add('C03',v,f,f'Where is the bounding-box center of the structure the {display(inst)} is {GERUND[verb].lower()} relative to the {display(ref)} center?',QUADS,ans,{'op':'action_target_quadrant','instrument':inst,'verb':verb,'reference':u[ref]},ans,self.run_episode(v,f,[(inst,verb,target)]));break
120
+ # Two spatial predicates intersect on exactly one known anatomy; each predicate has alternatives.
121
+ anatomies=[a for a in ANATOMIES if a in u]
122
+ refnames=[a for a in u if a in ANATOMIES or a in INSTRUMENTS and u[a] in toolids]
123
+ possibilities=list(itertools.combinations(refnames,2));self.rng.shuffle(possibilities);done=False
124
+ if len(anatomies)>=4:
125
+ for r1,r2 in possibilities[:12]:
126
+ for p,q in self.rng.sample(list(itertools.product(INV,repeat=2)),16):
127
+ universe=[a for a in anatomies if s.consistent(v,f,u[a],u[r1],p) and s.consistent(v,f,u[a],u[r2],q)]
128
+ A={a for a in universe if s.spatial(v,f,u[a],u[r1],p)};B={a for a in universe if s.spatial(v,f,u[a],u[r2],q)};I=A&B
129
+ if len(I)!=1 or len(A)<2 or len(B)<2 or len(universe)<4:continue
130
+ target=next(iter(I));d1=self.rng.choice(sorted(A-I));d2=self.rng.choice(sorted(B-I));rest=[a for a in universe if a not in [target,d1,d2]]
131
+ if not rest:continue
132
+ opts=[title(a) for a in [target,d1,d2,self.rng.choice(rest)]]
133
+ self.add('C04',v,f,f'Which structure has its bounding-box center both {self.phrase(p)} the {display(r1)} center and {self.phrase(q)} the {display(r2)} center?',opts,title(target),{'op':'spatial_intersection','references':[u[r1],u[r2]],'predicates':[p,q],'candidate_ids':[u[a] for a in universe]},target);done=True;break
134
+ if done:break
135
+ # Raw IVT categories support multi-instance class queries, without invented instance identity.
136
+ for inst,verb in sorted({t[:2] for t in ts}):
137
+ targets={t[2] for t in ts if t[:2]==(inst,verb)}
138
+ if len(targets)<2 or not targets<=set(anatomies):continue
139
+ for ref,p in itertools.product(refs,INV):
140
+ universe=[a for a in anatomies if s.consistent(v,f,u[a],u[ref],p)];B={a for a in universe if s.spatial(v,f,u[a],u[ref],p)};I=targets&B
141
+ if len(I)!=1 or len(B)<2 or len(universe)<4:continue
142
+ target=next(iter(I));neg=list(set(universe)-I);ans=title(target)
143
+ opts=[ans]+[title(a) for a in self.rng.sample(neg,3)]
144
+ self.add('C05',v,f,f'Which structure is both {PARTICIPLE[verb]} by a {display(inst)} and has its bounding-box center {self.phrase(p)} the {display(ref)} center?',opts,ans,{'op':'action_spatial_intersection','instrument':inst,'verb':verb,'reference':u[ref],'predicate':p,'candidate_ids':[u[a] for a in universe]},target,self.run_episode(v,f,[t for t in ts if t[:2]==(inst,verb)]));break
145
+ else:continue
146
+ break
147
+ # Relation-filtered counts use full instrument inventory. Positive and zero intersections allowed.
148
+ if complete_tools and 1<=len(toolids)<=3:
149
+ attempts=list(itertools.product(refs,INV,refs,INV));self.rng.shuffle(attempts)
150
+ emitted_counts=set()
151
+ for r1,p,r2,q in attempts[:90]:
152
+ if r1==r2 and p==q or p==INV[q] and r1==r2:continue
153
+ if any(not s.consistent(v,f,i,u[r1],p) or not s.consistent(v,f,i,u[r2],q) for i in toolids):continue
154
+ A={i for i in toolids if s.spatial(v,f,i,u[r1],p)};B={i for i in toolids if s.spatial(v,f,i,u[r2],q)};n=len(A&B)
155
+ if not A or not B or n in emitted_counts:continue
156
+ self.add('C06',v,f,f'How many instruments have bounding-box centers both {self.phrase(p)} the {display(r1)} center and {self.phrase(q)} the {display(r2)} center?',['0','1','2','3'],str(n),{'op':'spatial_count','references':[u[r1],u[r2]],'predicates':[p,q],'tool_ids':toolids},n,tags={'sets':[sorted(A),sorted(B)]});emitted_counts.add(n)
157
+ if len(emitted_counts)>=2:break
158
+ # Spatial target selection -> observed instrument, no planning/next-action claims.
159
+ if len({t[0] for t in facts})>=2 and {t[2] for t in ts} <= set(u):
160
+ targets={t[2] for t in facts}
161
+ for ref,p in itertools.product(refs,INV):
162
+ if any(not s.consistent(v,f,u[a],u[ref],p) for a in targets):continue
163
+ allowed={a for a in targets if s.spatial(v,f,u[a],u[ref],p)};insts={t[0] for t in facts if t[2] in allowed}
164
+ if len(insts)!=1 or not allowed or allowed==targets:continue
165
+ inst=next(iter(insts));ans=title(inst)
166
+ self.add('C07',v,f,f'Which instrument is acting on a structure whose bounding-box center is {self.phrase(p)} the {display(ref)} center?',self.opts(ans,[title(t) for t in INSTRUMENTS]),ans,{'op':'spatial_target_instrument','reference':u[ref],'predicate':p},inst);break
167
+ # CVS: every conflict-free labeled second in domain is eligible, not one-per-interval.
168
+ @staticmethod
169
+ def phrase(p):return {'left':'to the left of','right':'to the right of','above':'above','below':'below'}[p]
170
+ def cvs(self):
171
+ for v,good in self.s.cvt.items():
172
+ for f,r in good.items():
173
+ for k in range(4):
174
+ seg=r[f'episode_{k}']
175
+ if f<seg['start']+2 or f>seg['end']-2:continue
176
+ score=r['scores'][k] if k<3 else r['cv'];answer=CVS_OPTIONS[k][score]
177
+ self.add(f'V0{k+1}',v,f,CVS_QUESTIONS[k],CVS_OPTIONS[k],answer,{'op':'cvs','criterion':k,'scores':r['scores'],'rows':r['rows'],'label_source':r['source'],'segment':seg},str(score) if k<3 else answer,f'{v}:V{k+1}:{seg["start"]}:{seg["end"]}',tags={'calot_progress':self.calot_progress(v,f)})
178
+ def calot_progress(self,v,f):
179
+ x=self.s.phase[v];a=next(i for i,r in enumerate(x) if r['Phase_gt']==1);b=next(i for i,r in enumerate(x) if r['Phase_gt']==2)
180
+ return (f-a)/(b-a)
181
+ def dynamic(self):
182
+ s=self.s
183
+ for v in s.videos:
184
+ n=len(s.phase[v]);dtchoices=[3,5,8,10]
185
+ for f in range(3,n-13,2):
186
+ for dt in self.rng.sample(dtchoices,2):
187
+ h=f+dt
188
+ if (v,f) not in s.graphs or (v,h) not in s.graphs:continue
189
+ pres=[s.tools(v,t) for t in [f,h]]
190
+ if any(t is None for t in pres):continue
191
+ uu=[s.unique(v,t) for t in [f,h]];objs=[s.clean_objects(v,t) for t in [f,h]]
192
+ ts=[{x for x in s.ivt[v].get(t,set()) if x[1]!='null_verb' and x[2]!='null_target'} for t in [f,h]]
193
+ # Stable presence states, category-level observation of both endpoints.
194
+ tool=self.rng.choice(INSTRUMENTS);states=[tool in p for p in pres]
195
+ stable=all(s.tools(v,k) is not None and (tool in s.tools(v,k))==state for t,state in zip([f,h],states) for k in range(t-1,t+2))
196
+ if stable and all(not state or tool in u for state,u in zip(states,uu)):
197
+ opts=[f'{a} → {b}' for a,b in itertools.product(['Absent','Present'],repeat=2)];ans=' → '.join('Present' if b else 'Absent' for b in states)
198
+ self.add('D01',v,[f,h],f'Which pair describes {display(tool)} visibility in frame 1 and frame 2, in that order?',opts,ans,{'op':'temporal_presence','tool':tool},ans,tags={'tool':tool,'changed':states[0]!=states[1],'dt':dt})
199
+ common=[i for i in INSTRUMENTS if all(i in u and i in p for u,p in zip(uu,pres))]
200
+ for inst in common:
201
+ targets={t[2] for t in ts[0] if t[0]==inst}&{t[2] for t in ts[1] if t[0]==inst}
202
+ for target in sorted(targets):
203
+ verbs=[{t[1] for t in a if t[0]==inst and t[2]==target} for a in ts]
204
+ if any(len(x)!=1 for x in verbs):continue
205
+ aa=[next(iter(x)) for x in verbs]
206
+ if not all({x[1] for x in s.ivt[v].get(k,set()) if x[0]==inst and x[2]==target}=={a} for t,a in zip([f,h],aa) for k in range(t-1,t+2)):continue
207
+ av=list(dict.fromkeys(aa))
208
+ if len(av)==1:
209
+ other=[a for a in self.inst_verbs[inst] if a not in av]
210
+ if not other:continue
211
+ av.append(self.rng.choice(other))
212
+ fmt=lambda a,b:f'{GERUND[a]} → {GERUND[b]}'
213
+ opts=[fmt(a,b) for a,b in itertools.product(av,repeat=2)];ans=fmt(*aa)
214
+ self.add('D02',v,[f,h],f'What is the {display(inst)} doing to the {display(target)} in frame 1 and frame 2, respectively?',opts,ans,{'op':'temporal_verb','instrument':inst,'target':target},ans,tags={'instrument':inst,'target':target,'changed':aa[0]!=aa[1],'dt':dt});break
215
+ verbs={t[1] for t in ts[0] if t[0]==inst}&{t[1] for t in ts[1] if t[0]==inst}
216
+ for verb in sorted(verbs):
217
+ tt=[{t[2] for t in a if t[:2]==(inst,verb)} for a in ts]
218
+ if any(len(x)!=1 for x in tt):continue
219
+ aa=[next(iter(x)) for x in tt]
220
+ if not all({x[2] for x in s.ivt[v].get(k,set()) if x[:2]==(inst,verb)}=={a} for t,a in zip([f,h],aa) for k in range(t-1,t+2)):continue
221
+ av=list(dict.fromkeys(aa))
222
+ if len(av)==1:av.append(self.rng.choice([a for a in self.all_targets if a not in av]))
223
+ fmt=lambda a,b:f'{title(a)} → {title(b)}';opts=[fmt(a,b) for a,b in itertools.product(av,repeat=2)];ans=fmt(*aa)
224
+ self.add('D03',v,[f,h],f'Which target is the {display(inst)} {GERUND[verb].lower()} in frame 1 and frame 2, respectively?',opts,ans,{'op':'temporal_target','instrument':inst,'verb':verb},ans,tags={'instrument':inst,'verb':verb,'changed':aa[0]!=aa[1],'dt':dt});break
225
+ phases=[int(s.phase[v][t]['Phase_gt']) for t in [f,h]]
226
+ if min(phases)>0 and all(int(s.phase[v][k]['Phase_gt'])==p for t,p in zip([f,h],phases) for k in range(t-1,t+2)):
227
+ av=list(dict.fromkeys(phases))
228
+ if len(av)==1:av.append(self.rng.choice([p for p in range(1,7) if p not in av]))
229
+ fmt=lambda a,b:f'{PHASES[a]} → {PHASES[b]}';opts=[fmt(a,b) for a,b in itertools.product(av,repeat=2)];ans=fmt(*phases)
230
+ self.add('D04',v,[f,h],'Which surgical phase is shown in frame 1 and frame 2, respectively?',opts,ans,{'op':'temporal_phase'},ans,tags={'changed':phases[0]!=phases[1],'dt':dt})
231
+ for inst in common:
232
+ refs=[a for a in ANATOMIES if all(a in u for u in uu)];self.rng.shuffle(refs)
233
+ for ref in refs[:2]:
234
+ for dirs in [('left','right'),('above','below')]:
235
+ vals=[]
236
+ for t,u in zip([f,h],uu):
237
+ vv=[p for p in dirs if s.spatial(v,t,u[inst],u[ref],p)]
238
+ if len(vv)!=1:break
239
+ vals.append(vv[0])
240
+ if len(vals)!=2:continue
241
+ fmt=lambda a,b:f'{a.capitalize()} → {b.capitalize()}';opts=[fmt(a,b) for a,b in itertools.product(dirs,repeat=2)];ans=fmt(*vals)
242
+ self.add('D05',v,[f,h],f'Relative to the {display(ref)} bounding-box center, is the {display(inst)} center {dirs[0]} or {dirs[1]} in frame 1 and frame 2, respectively?',opts,ans,{'op':'temporal_spatial','instrument':inst,'reference':ref,'axis':list(dirs)},ans,tags={'changed':vals[0]!=vals[1],'dt':dt})
243
+ break
244
+ else:continue
245
+ break
246
+
247
+ def main():
248
+ p=argparse.ArgumentParser();p.add_argument('--ori',default='/home/ach18533cl/workspace/ori_data');p.add_argument('--root',default='/home/ach18533cl/workspace/SceneBench');a=p.parse_args();root=Path(a.root);cfg=json.loads((root/'config.json').read_text());s=Sources(a.ori,cfg['test_videos']);gen=Generator(s,cfg)
249
+ for v in s.videos:
250
+ for f in range(0,len(s.phase[v]),2):gen.frame(v,f)
251
+ print('Generated single frames',v,{k:len(x) for k,x in gen.pool.items()},flush=True)
252
+ gen.cvs();gen.dynamic()
253
+ for k,rows in gen.pool.items():write_jsonl(root/f'work/candidates/{k}.jsonl',rows)
254
+ write_json(root/'work/pool_summary.json',dict(counts={k:len(x) for k,x in gen.pool.items()},answers={k:dict(collections.Counter(x['answer_class'] for x in rr)) for k,rr in gen.pool.items()},source_rejections=dict(s.counts)))
255
+ write_json(root/'work/source_cvs_rows.json',s.cvs_rows)
256
+ print('DONE', {k:len(x) for k,x in gen.pool.items()},flush=True)
257
+ if __name__=='__main__':main()
code/package_release.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json,hashlib,collections,shutil,datetime,platform
2
+ from pathlib import Path
3
+ from datasets import Dataset,Features,Value,Sequence,Image as HFImage,load_dataset
4
+ from common import read_jsonl,write_json
5
+
6
+ root=Path('/home/ach18533cl/workspace/SceneBench');release=root/'release';hf=root/'huggingface';hf.mkdir(exist_ok=True);docs=root/'docs';docs.mkdir(exist_ok=True)
7
+ cfg=json.loads((root/'config.json').read_text());rows=list(read_jsonl(release/'benchmark.jsonl'));valid=json.loads((release/'validation_report.json').read_text());assert valid['status']=='pass' and valid['items']==len(rows)
8
+ cur=json.loads((release/'curation_report.json').read_text());sha=hashlib.sha256((release/'benchmark.jsonl').read_bytes()).hexdigest()
9
+ families=['Perception','Relation','Composition','Procedure','CVS','Dynamic'];cn=['感知','关系','组合','流程','CVS','动态'];counts=collections.Counter(r['family'] for r in rows);tc=collections.Counter(r['task'] for r in rows)
10
+ task_names=dict(zip(cfg['target_counts'],['器械定位识别','解剖结构定位识别','器械存在性','同类器械计数','器械绝对方位','动作识别','动作主体识别','动作目标识别','器械相对解剖结构方位','解剖结构相对器械方位','解剖结构之间方位','两个动作的有序目标组合','空间筛选器械后查询目标','动作目标的相对方位','两个空间条件的交集','动作与空间条件的交集','两个空间条件下的器械计数','空间筛选目标后查询器械','当前手术阶段','两结构标准评分','胆囊板标准评分','肝胆三角标准评分','整体 CVS 是否达到','器械存在状态变化','动作状态变化','作用目标变化','手术阶段变化','空间关系变化']))
11
+ frozen={'version':cfg['version'],'benchmark_sha256':sha,'items':len(rows),'created_utc':datetime.datetime.now(datetime.timezone.utc).isoformat(),'curation_before_baseline':True}
12
+ write_json(release/'FROZEN.json',frozen)
13
+ stats={'items':len(rows),'unique_source_frames':valid['unique_source_frames'],'unique_exported_images':len({p for r in rows for p in r['images']}),'family_counts':dict(counts),'task_counts':dict(tc),'videos':dict(collections.Counter(r['video_id'] for r in rows)),'answer_classes':valid['answer_classes'],'answer_positions':valid['answer_positions'],'cvs':{}}
14
+ for t in ['V01','V02','V03','V04']:
15
+ rr=[r for r in rows if r['task']==t];stats['cvs'][t]={a:{'questions':sum(r['answer_class']==a for r in rr),'videos':sorted({r['video_id'] for r in rr if r['answer_class']==a}),'segments':len({r['episode_id'] for r in rr if r['answer_class']==a}),'label_sources':dict(collections.Counter(r['query']['label_source'] for r in rr if r['answer_class']==a))} for a in sorted({r['answer_class'] for r in rr})}
16
+ write_json(release/'dataset_statistics.json',stats)
17
+ lines=[f'# SceneBench v{cfg["version"]}:Benchmark 说明', '',f'本版本共 **{len(rows)} 题、6 层、28 个题型**,全部从原始数据重新生成。仅发布 test 集;没有复用旧版 2300 题,也没有另外划主榜或子榜。', '', '## 数据与输入', '', '固定视频:VID02、VID06、VID14、VID23、VID25、VID50、VID51、VID66、VID79。训练和验证数据应继续使用这些测试视频以外的手术,不能按帧把同一测试视频混入训练。', '',f'共有 {stats["unique_source_frames"]} 个不同的原始 1 fps 帧、{stats["unique_exported_images"]} 个导出图像文件。P/R/C/PR/V 均为单帧;只有 D 为按时间排序的两帧,间隔 3、5、8 或 10 秒。没有要求生成长时序 graph。', '', '问答使用英语。P03、V04 为二选一;V01–V03 保留原生 0/1/2 三级评分,为三选一;其余题型为四选一。每题只有一个可由完整查询确定的正确选项;R 类若同一查询存在多个动作、主体或目标,就不生成该候选。空间关系将横纵方向合成互斥四象限,避免“左”和“上”同时正确。', '', '## 各层数量', '', '| 层 | 目标 | 最终 |', '|---|---:|---:|']
18
+ for f,n in zip(families,cn):lines.append(f'| {n} | {sum(cfg["target_counts"][t] for t in tc if next(r["family"] for r in rows if r["task"]==t)==f)} | {counts[f]} |')
19
+ lines+=['',f'候选抽样得到 {cur["initial"]} 题,图像复核剔除 {cur["dropped"]} 题,修正 {cur["point_corrections"]} 个箭头落点。C05、D02、V04 在初次抽样时已有候选容量缺口;进一步复核导致 P01/P02/P04/C04/C06 减少。没有用重复题或放宽 GT 唯一性来补齐目标。', '', '## 每个题型的真实问答示例', '', '下列示例均直接来自本次冻结的 benchmark.jsonl。选项顺序、答案与样本 ID 一致。完整证据见同 ID 的 source_evidence、query、marker 字段。', '']
20
+ for t in cfg['target_counts']:
21
+ r=next(r for r in rows if r['task']==t);lines += [f'### {t} · {task_names[t]}({tc[t]} 题)','',f'样本 `{r["id"]}`;来源 `{r["video_id"]}`,1 fps 帧 `{r["frame_ids"]}`。', '',r['question'],'']+[f'- {chr(65+i)}. {a}' for i,a in enumerate(r['options'])]+['',f'正确答案:**{r["answer"]}. {r["answer_text"]}**。','']
22
+ lines += ['## Ground truth 与可追溯性', '', '原始目录为 `/home/ach18533cl/workspace/ori_data`。', '', '- 图像:`CholecT45/data/VIDxx/ffffff.png`。1 fps 帧索引从 0 开始,对应 Cholec80 原始 25 fps 帧号 `25 × f`;对九个视频逐帧验证了该映射。','- 动作与目标:`CholecT45/triplet/VIDxx.txt` 及 `dict/`。R01–R03、动作组合和动态动作使用真实 IVT;排除 null 动作/目标及完整查询多解。','- 阶段与器械存在:` Cholec80_labels/labels/{train,val,test}/...pickle`,目录名开头有一个空格。`Tool_gt=None` 视为缺失,不能当作不存在。','- 空间、类别、实例数:`scene_graph/VIDxx_f.json` 的 `scenes[0]`。保留原始对象、bbox、center 与关系。坐标画布为 430×240。`a in right[b]` 表示 a 在 b 右侧;用坐标和反向边同时验证,不能照 README 中相反方向的文字例子实现。','- CVS:`Cholec80_CVS/cholec80-CVS.xlsx` 的分段评分,并记录原 Excel 行号和标签来源。现有 VQA 文本没有用来改写旧题或替代证据。', '', '图结构中的 bbox 和部分解剖类别来自自动检测/图生成,不等同于逐帧专家金标准。本版本保证答案可由保存的源标注与确定规则重算,并做了图像质量筛选及分层视觉复核;不能声称每条源标注都经外科专家确认。P01/P02/P04/C06 对全部初选样本做视觉筛查,C04/C05/CVS 做按答案分层抽查。复核发现的明显重复检测、错框、模糊目标已剔除。该边界也适用于评测得分的解释。', '', '## Marker 与图像处理', '', 'P01 的黄色 A 框和 P02 的黄色 A 箭头已画入实际导出 JPEG,也已嵌入 Hugging Face 的图像字节。框来自源 bbox;箭头指向源 bbox 内经视觉筛查的落点,18 处作了修正(实际列表见 curation_report.json)。没有把答案类别文字写入图像。', '', '按原图宽高分别从 430×240 映射坐标;最长边最多 1280 像素,JPEG quality 95。没有裁剪、翻转或更改时间顺序。原图路径、输出尺寸和 SHA256 均可追溯。诊断用的多框复核图不作为模型输入。', '', '## 重新抽样规则', '', '先建立所有题型的合格候选,再按题型配额轮转,并优先选择不足的答案类和视频,避免高频、易生成题占满。普通候选扫描步长 2 秒,CVS 在有效域逐秒扫描;动态候选检查两个端点的真实标签。PR01 每个有数据的阶段 50 题,Preparation 不在这些 CholecT45 测试帧的有效阶段库存中。', '', '同视频同题型普通题至少间隔 10 秒,CVS 至少 3 秒。每个原始帧最多用于 2 题;动态两帧端点由该动态题独占。同类动作题每个动作持续事件至多取一次。CVS 每个连续同标签区间每题型最多 15 帧,允许区间内多个代表帧;结合亮度、清晰度和 dHash 去重。最终选项答案位置在每个题型内计数最多相差 1。复核后的语义类别分布不强行补齐,实际分布见 dataset_statistics.json。', '', 'D02 描述的是同一器械类别在同一目标上的端点动作变化;未提供器械实例 tracking ID,所以不把它解释为同一物理实例的连续追踪。动态样本包含稳定与变化情况,单侧上限 60%,稀有变化不足时允许数量缺口。', '', '## CVS 的区间规则与限制', '', '已核对 [Cholec80-CVS 论文](https://www.nature.com/articles/s41597-023-02073-7) 和官方转换脚本:标注区间内所有帧共享区间标签;有效标注域内未覆盖片段默认三项为 0。**不能把最近一次非零标签一直向后填充。** 官方实现本身可在区间内以 5 fps 输出,原来“一段只取一帧”并非数据集要求。', '', '本版本进一步限制在 Calot triangle dissection 阶段且首次 clipping/cutting 之前。区间两端包含在内;多行覆盖且评分冲突的秒被剔除。V01–V03 分别使用原始三级评分;V04 按该数据集规则 `sum(V01,V02,V03) >= 5`,不是要求三项全为 2,也不是独立临床认证。', '', 'V04 的 3 个阳性问题仅来自 VID66 的 661–675 秒这一个阳性事件;V03 的 2 分同样集中于此。V02 的 2 分仅来自 VID51 的两个区间。这些帧增加视角/遮挡覆盖,不能当成多个独立手术或多个独立阳性事件。已把部分 V04 阴性替换为 VID66 相近手术进度的帧;其余阴性也限制在较晚 Calot,减少容易的阶段线索。', '', '| CVS 题型 | 答案类 | 问题数 | 视频数 | 连续标签区间数 |', '|---|---|---:|---:|---:|']
23
+ for t,aa in stats['cvs'].items():
24
+ for a,st in aa.items():lines.append(f'| {t} | {a} | {st["questions"]} | {len(st["videos"])} | {st["segments"]} |')
25
+ lines += ['', '整体 CVS 阴性不妨碍生成 V01–V03:它仍然可能只有某些标准达到 1 或 2 分。结果应报告每项每分值表现;只有一个独立阳性事件的 V04 不能支持可靠的跨手术敏感度结论。', '', '## 文件与复现', '', '- `release/benchmark.jsonl`:全部题目、相对图像路���、GT、原始证据和生成查询。','- `release/images/`:最终模型输入图像,包含实际 marker。','- `release/validation_report.json`:逐题重算、唯一性、图像哈希、分集、复用和答案位置检查。','- `release/curation_report.json`:剔除记录、箭头修正、阴性匹配替换和复核范围。','- `huggingface/data/test-*.parquet`:嵌入图像字节的便携数据集,可直接 load_dataset。','- `docs/Benchmark说明_20260922.md`:本说明;评测完成后另写结果分析。','- `evaluation/`:完整请求协议、原始回答、统计与分析。', '',f'随机种子 `{cfg["seed"]}`;版本 `{cfg["version"]}`;冻结 SHA256 `{sha}`。', '', '```bash', '.venv/bin/python generate.py', '.venv/bin/python select_render.py', '.venv/bin/python curate.py', '.venv/bin/python validate.py', '.venv/bin/python package_release.py', '.venv/bin/python evaluate_openrouter.py', '```', '', '复现视觉决策使用 curation.json;不要在已有评测结果后覆盖冻结问题。源数据需另行放在上述 ori_data 路径。依赖见 requirements-lock.txt。', '', '## 发布与许可', '', 'Hugging Face:`EgoF0102/SceneBench`,本次默认私有仓库。图像和衍生标注遵循源数据的 CC BY-NC-SA 4.0;需保留源数据引用与署名,限非商业用途,衍生共享使用相同许可。引用 Cholec80/EndoNet、CholecT45/Rendezvous、SSG-VQA 与 Cholec80-CVS。']
26
+ (docs/'Benchmark说明_20260922.md').write_text('\n'.join(lines)+'\n')
27
+ features=Features({'id':Value('string'),'split':Value('string'),'task':Value('string'),'family':Value('string'),'question':Value('string'),'options':Sequence(Value('string')),'answer':Value('string'),'answer_index':Value('int32'),'answer_text':Value('string'),'answer_class':Value('string'),'images':Sequence(HFImage()),'video_id':Value('string'),'frame_ids':Sequence(Value('int32')),'episode_id':Value('string'),'marker_json':Value('string'),'provenance_json':Value('string')})
28
+ def converted(r):
29
+ x={k:r[k] for k in features if k not in ['images','marker_json','provenance_json']};x['images']=[{'bytes':(release/p).read_bytes(),'path':Path(p).name} for p in r['images']];x['marker_json']=json.dumps(r['marker'],ensure_ascii=False);x['provenance_json']=json.dumps({k:r[k] for k in ['candidate_id','query','tags','source_frame_ids','source_evidence','quality_status','image_metadata']},ensure_ascii=False);return x
30
+ (hf/'data').mkdir(exist_ok=True)
31
+ shards=6
32
+ for i in range(shards):
33
+ subset=rows[i*len(rows)//shards:(i+1)*len(rows)//shards];ds=Dataset.from_list([converted(r) for r in subset],features=features);ds.to_parquet(hf/f'data/test-{i:05d}-of-{shards:05d}.parquet')
34
+ check=load_dataset('parquet',data_files={'test':str(hf/'data/test-*.parquet')},split='test');assert len(check)==len(rows);assert check[0]['images'][0].width>0;assert len(check[-1]['images'])==2
35
+ for name in ['FROZEN.json','config.json','validation_report.json','curation_report.json','dataset_statistics.json']:shutil.copy(release/name,hf/name)
36
+ (hf/'docs').mkdir(exist_ok=True);shutil.copy(docs/'Benchmark说明_20260922.md',hf/'docs')
37
+ (hf/'code').mkdir(exist_ok=True)
38
+ for name in ['common.py','generate.py','select_render.py','curate.py','curation.json','validate.py','package_release.py','evaluate_openrouter.py','config.json']:
39
+ shutil.copy(root/name,hf/'code'/name)
40
+ if (root/'requirements-lock.txt').exists():shutil.copy(root/'requirements-lock.txt',hf/'code')
41
+ card=f'''---
42
+ license: cc-by-nc-sa-4.0
43
+ task_categories:
44
+ - visual-question-answering
45
+ language:
46
+ - en
47
+ tags:
48
+ - surgery
49
+ - laparoscopic-cholecystectomy
50
+ - scene-graph
51
+ size_categories:
52
+ - 1K<n<10K
53
+ configs:
54
+ - config_name: default
55
+ data_files:
56
+ - split: test
57
+ path: data/test-*.parquet
58
+ ---
59
+ # SceneBench v{cfg['version']}
60
+
61
+ {len(rows)} source-derived multiple-choice questions across 28 task types and six families, generated anew from nine held-out CholecT45 videos. One test benchmark; no training or validation split is distributed.
62
+
63
+ | Family | Questions |
64
+ |---|---:|
65
+ '''+''.join(f'| {f} | {counts[f]} |\n' for f in families)+f'''
66
+ ## Loading
67
+
68
+ ```python
69
+ from datasets import load_dataset
70
+ ds = load_dataset("EgoF0102/SceneBench", split="test", token=True)
71
+ row = ds[0]
72
+ images = row["images"] # List of PIL images; one, or two in chronological order.
73
+ print(row["question"], row["options"], row["answer"])
74
+ ```
75
+
76
+ Image bytes are embedded in Parquet. Yellow box A / arrow A is already rendered for P01/P02. Do not pass answer fields, provenance, video IDs, timestamps or source graphs to a direct-VQA baseline. Options are presented in stored order. P03/V04 have 2 options, V01–V03 have 3, all others have 4. The answer letter is determined by answer_index. Each question has one source-derived answer.
77
+
78
+ ## Sources and split
79
+
80
+ Test videos: VID02, VID06, VID14, VID23, VID25, VID50, VID51, VID66, VID79. All other videos must remain outside this test split when constructing training data. Indices are zero-based 1 fps indices; original Cholec80 frame index is 25 times this index.
81
+
82
+ - [Cholec80 / EndoNet](https://github.com/CAMMA-public/Cholec80): phase and tool presence.
83
+ - [CholecT45 / Rendezvous](https://github.com/CAMMA-public/cholect45): images and instrument-verb-target annotations. Cite Nwoye et al., *Rendezvous: Attention Mechanisms for the Recognition of Surgical Action Triplets in Endoscopic Videos*, Medical Image Analysis, 2022.
84
+ - [SSG-VQA](https://arxiv.org/abs/2312.10251): supplied scene graphs, object categories, boxes and spatial relations; cite Yuan et al., *Advancing Surgical VQA with Scene Graph Knowledge*, 2023. See local source provenance for exact records.
85
+ - [Cholec80-CVS](https://www.nature.com/articles/s41597-023-02073-7): segmented CVS criterion scores. Follow the original paper and source repositories for full author attribution and citations.
86
+
87
+ ## Generation and quality
88
+
89
+ Queries are deterministic functions of source labels. Ambiguous action queries are rejected. Spatial directions use 430×240 bbox-center geometry, a 5% axis margin, and matching positive/inverse relation edges. Graph-detected tool categories are cross-checked against source tool-presence labels. Per-task answer/video balancing, spacing and image deduplication limit repetition; actual counts and distributions are in dataset_statistics.json. Source frames are reused at most twice, and Dynamic endpoints are exclusive to their one pair. Dynamic questions compare two endpoint states, not tracked physical instrument identities.
90
+
91
+ {cur['dropped']} of {cur['initial']} selected candidates were removed during visual screening; {cur['point_corrections']} anatomy arrow tips were adjusted within the source box. P01/P02/P04/C06 received screening of all selected items; C04/C05/CVS received answer-stratified screening. This was Codex visual screening, not expert surgical adjudication. The source scene graphs contain model-generated detections and can contain residual errors. **This release is source-consistent, not a claim of independently expert-verified gold for every image.** Review scope and exclusions are public in curation_report.json. No baseline predictions were used for curation.
92
+
93
+ ## CVS interpretation
94
+
95
+ Only Calot triangle dissection before the first clipping/cutting transition is eligible. Annotated intervals include both endpoints. Uncovered segments inside the valid domain default to (0,0,0); labels are not forward-filled. Conflicting overlapping scores are excluded. V01–V03 use the native 0/1/2 criterion scores; V04 follows the source rule total score >=5. This is a dataset convention, not independent clinical certification. Multiple spaced/deduplicated frames per interval are allowed.
96
+
97
+ V04 has only three positive frames, all from one event in VID66 (661–675 seconds). V03 score 2 has the same event concentration. V02 score 2 occurs in two VID51 intervals. Multiple frames do not create independent clinical events. Some V04 negatives are matched to VID66 and late Calot. Results for rare criteria must be interpreted at video/event level.
98
+
99
+ ## Evaluation
100
+
101
+ The baseline protocol uses `qwen/qwen3-vl-32b-instruct` through OpenRouter, temperature 0, one call per question, only exported images + question/options, returning a single option letter. It is a zero-shot base-Instruct direct-VQA baseline, without SFT/RL or predicted-graph conditioning. Results and a separate Chinese analysis document are added after complete evaluation. Total micro accuracy and descriptive family/task/class breakdowns refer to this same benchmark.
102
+
103
+ ## License and reproducibility
104
+
105
+ CC BY-NC-SA 4.0. Images and source-derived annotations retain source attribution, non-commercial restrictions and share-alike terms. See [the license](https://creativecommons.org/licenses/by-nc-sa/4.0/) and original source publications. Export processing adds markers, resizes longest edge to at most 1280 and encodes JPEG quality 95; no crop or flip.
106
+
107
+ Full Chinese task definitions, real examples, source mapping, sampling and limitations: [Benchmark说明](docs/Benchmark说明_20260922.md). Generator, fixed curation decisions and validator: code/. Credentials and raw unused source data are not included.
108
+
109
+ Frozen benchmark SHA256: `{sha}`.
110
+ '''
111
+ (hf/'README.md').write_text(card);(hf/'LICENSE').write_text('Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International\nhttps://creativecommons.org/licenses/by-nc-sa/4.0/legalcode\nSource images and annotations retain their respective original authors and attribution.\n')
112
+ write_json(root/'work/package_report.json',dict(status='pass',parquet_rows=len(check),parquet_shards=shards,benchmark_sha256=sha,embedded_images_verified=True))
113
+ print(json.dumps({'items':len(rows),'families':dict(counts),'sha256':sha,'parquet_check':'pass'}),flush=True)
code/requirements-lock.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohappyeyeballs==2.6.1
2
+ aiohttp==3.13.5
3
+ aiosignal==1.4.0
4
+ annotated-doc==0.0.5
5
+ anyio==4.12.1
6
+ async-timeout==5.0.1
7
+ attrs==26.1.0
8
+ certifi==2026.7.22
9
+ charset-normalizer==3.5.1
10
+ click==8.1.8
11
+ datasets==4.5.0
12
+ dill==0.4.0
13
+ et_xmlfile==2.0.0
14
+ exceptiongroup==1.3.1
15
+ filelock==3.19.1
16
+ frozenlist==1.8.0
17
+ fsspec==2025.10.0
18
+ h11==0.16.0
19
+ hf-xet==1.6.0
20
+ httpcore==1.0.9
21
+ httpx==0.28.1
22
+ huggingface_hub==1.8.0
23
+ idna==3.20
24
+ markdown-it-py==3.0.0
25
+ mdurl==0.1.2
26
+ multidict==6.7.1
27
+ multiprocess==0.70.18
28
+ numpy==2.0.2
29
+ openpyxl==3.1.5
30
+ packaging==26.3
31
+ pandas==2.3.3
32
+ pillow==11.3.0
33
+ propcache==0.4.1
34
+ pyarrow==21.0.0
35
+ Pygments==2.21.0
36
+ python-dateutil==2.9.0.post0
37
+ pytz==2026.3.post1
38
+ PyYAML==6.0.3
39
+ requests==2.32.5
40
+ rich==15.0.0
41
+ shellingham==1.5.4
42
+ six==1.17.0
43
+ tqdm==4.70.1
44
+ typer==0.23.2
45
+ typing_extensions==4.16.0
46
+ tzdata==2026.4
47
+ urllib3==2.6.3
48
+ xxhash==4.0.1
49
+ yarl==1.22.0
code/select_render.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json,random,collections,math,hashlib,shutil
2
+ from pathlib import Path
3
+ from PIL import Image,ImageDraw,ImageFont,ImageFilter
4
+ import numpy as np
5
+ from common import *
6
+
7
+ def image_stats(path):
8
+ im=Image.open(path).convert('RGB');small=im.resize((128,72));a=np.asarray(small.convert('L'),dtype=float);center=a[8:64,12:116]
9
+ gradient=float(np.abs(np.diff(center,axis=0)).mean()+np.abs(np.diff(center,axis=1)).mean())
10
+ valid=float((a>18).mean())>.35 and float(a.std())>14 and float((center>247).mean())<.5 and gradient>2
11
+ b=np.asarray(im.convert('L').resize((9,8)));bits=(b[:,1:]>b[:,:-1]).ravel();h=sum(int(x)<<i for i,x in enumerate(bits))
12
+ return dict(valid=bool(valid),width=im.width,height=im.height,std=float(a.std()),gradient=gradient,dhash=f'{h:016x}',sha256=hashlib.sha256(Path(path).read_bytes()).hexdigest())
13
+
14
+ class Selector:
15
+ def __init__(self,s,root,cfg):
16
+ self.s=s;self.root=root;self.cfg=cfg;self.rng=random.Random(cfg['seed']+1);self.used=collections.Counter();self.used_tasks=collections.defaultdict(set);self.dynamic_reserved=set();self.times=collections.defaultdict(list);self.episodes=collections.Counter();self.hashes=collections.defaultdict(list);self.stats={};self.rejected=collections.Counter();self.selected=[]
17
+ self.excluded_frames=set();self.excluded_candidates=set()
18
+ p=root/'work/review_exclusions.json'
19
+ if p.exists():
20
+ e=json.loads(p.read_text());self.excluded_candidates.update(e.get('candidate_ids',[]));self.excluded_frames.update((int(v),int(f)) for v,f in e.get('frames',[]))
21
+ p=root/'work/image_stats.json'
22
+ if p.exists():self.stats=json.loads(p.read_text())
23
+ def allowed(self,c):
24
+ if c['candidate_id'] in self.excluded_candidates:return False
25
+ v=c['video'];task=c['task'];fs=c['frames'];cvs=task.startswith('V');dynamic=task.startswith('D')
26
+ for f in fs:
27
+ key=(v,f)
28
+ if key in self.excluded_frames or key in self.dynamic_reserved:return False
29
+ if dynamic and self.used[key]:return False
30
+ if self.used[key]>=2:return False
31
+ if task in self.used_tasks[key]:return False
32
+ if task.startswith('R') and any(t.startswith('R') for t in self.used_tasks[key]):return False
33
+ dt=3 if cvs else 10
34
+ if any(abs(fs[0]-t)<dt for t in self.times[v,task]):return False
35
+ # Restrict repeated action facts for the same task and episode, not all frames of a CVS interval.
36
+ if not cvs and task in ['R01','R02','R03','C01','C03','C05'] and self.episodes[task,c['episode']]>=1:return False
37
+ if cvs and self.episodes[task,c['episode']]>=15:return False
38
+ # V04 negatives are phase/progress matched, not early all-zero easy cases.
39
+ if task=='V04' and c['answer_class']=='No' and c['tags']['calot_progress']<.65:return False
40
+ for f in fs:
41
+ kk=f'{v}:{f}'
42
+ if kk not in self.stats:
43
+ try:self.stats[kk]=image_stats(self.s.image_path(v,f))
44
+ except Exception:self.stats[kk]={'valid':False}
45
+ st=self.stats[kk]
46
+ if not st['valid']:self.rejected['image_quality']+=1;return False
47
+ hh=int(st['dhash'],16)
48
+ if any(bin(hh^int(old,16)).count('1')<=1 for old in self.hashes[v,task]):self.rejected['near_duplicate']+=1;return False
49
+ # A proposed anatomy arrow must avoid black regions and detected instrument bodies.
50
+ if c.get('marker') and c['marker']['kind']=='arrow':
51
+ m=c['marker'];im=Image.open(self.s.image_path(v,fs[0])).convert('RGB');g=self.s.graphs[v,fs[0]];x,y,X,Y=m['bbox'];points=[]
52
+ for px,py in [(m['point'][0],m['point'][1])]+[(x+(X-x)*a,y+(Y-y)*b) for a in [.35,.5,.65] for b in [.35,.5,.65]]:
53
+ if any(o['bbox'][0]-3<=px<=o['bbox'][2]+3 and o['bbox'][1]-3<=py<=o['bbox'][3]+3 for o in g['objects'] if o['type']=='instrument'):continue
54
+ xx=min(im.width-1,round(px/430*im.width));yy=min(im.height-1,round(py/240*im.height));pixel=im.getpixel((xx,yy))
55
+ if max(pixel)<45 or min(pixel)>245:continue
56
+ points.append([px,py])
57
+ if not points:return False
58
+ m['point']=points[0]
59
+ return True
60
+ def accept(self,c):
61
+ v=c['video'];task=c['task'];fs=c['frames'];self.selected.append(c)
62
+ for f in fs:
63
+ self.used[v,f]+=1;self.used_tasks[v,f].add(task);self.hashes[v,task].append(self.stats[f'{v}:{f}']['dhash'])
64
+ if task.startswith('D'):self.dynamic_reserved.add((v,f))
65
+ self.times[v,task].append(fs[0]);self.episodes[task,c['episode']]+=1
66
+ def select_task(self,task):
67
+ rows=list(read_jsonl(self.root/f'work/candidates/{task}.jsonl'));self.rng.shuffle(rows);target=self.cfg['target_counts'][task]
68
+ buckets=collections.defaultdict(lambda:collections.defaultdict(list))
69
+ for r in rows:buckets[r['answer_class']][r['video']].append(r)
70
+ classes=sorted(buckets);self.rng.shuffle(classes);counts=collections.Counter();videos=collections.Counter();tags=collections.Counter();changed=collections.Counter();selected=[]
71
+ explicit=self.cfg.get('cvs_answer_targets',{}).get(task)
72
+ # PR01 uses 50 questions per phase; other tasks balance only supported answer strata.
73
+ if task=='PR01':explicit={str(p):50 for p in range(1,7)}
74
+ cap_video=max(2,math.ceil(target/len(self.s.videos)*1.65))
75
+ rounds=0
76
+ while len(selected)<target:
77
+ available=[a for a in classes if any(buckets[a].values()) and (not explicit or counts[a]<explicit.get(a,0))]
78
+ if not available:break
79
+ available.sort(key=lambda a:(counts[a]/max(1,explicit.get(a,1)) if explicit else counts[a],self.rng.random()))
80
+ accepted=False
81
+ for ans in available:
82
+ vv=[v for v in buckets[ans] if buckets[ans][v]]
83
+ vv.sort(key=lambda v:(videos[v],self.rng.random()))
84
+ for v in vv:
85
+ if not task.startswith('V') and videos[v]>=cap_video:continue
86
+ while buckets[ans][v]:
87
+ c=buckets[ans][v].pop()
88
+ # Prevent a temporal question family from containing only stable endpoints.
89
+ if task.startswith('D') and changed[c['tags']['changed']]>=math.ceil(target*.6):continue
90
+ if not self.allowed(c):continue
91
+ self.accept(c);selected.append(c);counts[ans]+=1;videos[v]+=1
92
+ if task.startswith('D'):changed[c['tags']['changed']]+=1
93
+ accepted=True;break
94
+ if accepted:break
95
+ if accepted:break
96
+ if not accepted:break
97
+ rounds+=1
98
+ # CVS 0/1 redistribution only within the same question type if scarce 2-point slots fail QA.
99
+ if len(selected)<target and explicit and task in ['V01','V02','V03']:
100
+ for ans in ['0','1']:
101
+ vv=list(buckets.get(ans,{}));self.rng.shuffle(vv)
102
+ for v in vv:
103
+ while buckets[ans][v] and len(selected)<target and counts[ans]<math.ceil(target*.5):
104
+ c=buckets[ans][v].pop()
105
+ if self.allowed(c):self.accept(c);selected.append(c);counts[ans]+=1;videos[v]+=1
106
+ print('SELECT',task,len(selected),'of',target,'answers',dict(counts),'videos',dict(videos),flush=True)
107
+ return dict(target=target,selected=len(selected),answers=dict(counts),videos=dict(videos),temporal_changed=dict(changed))
108
+
109
+ def font(size):
110
+ for p in ['/usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf','/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf']:
111
+ if Path(p).exists():return ImageFont.truetype(p,size)
112
+ return ImageFont.load_default()
113
+
114
+ def render(c,source,dest,cfg):
115
+ im=Image.open(source).convert('RGB');im.thumbnail((cfg['max_export_image_dimension'],cfg['max_export_image_dimension']),Image.Resampling.LANCZOS);m=c.get('marker');W,H=im.size
116
+ if m:
117
+ d=ImageDraw.Draw(im);scale=lambda p:(p[0]/430*W,p[1]/240*H);lw=max(2,round(W/450));size=max(20,round(H*.045));ft=font(size);color='#FFE33B'
118
+ if m['kind']=='box':
119
+ a,b=scale(m['bbox'][:2]),scale(m['bbox'][2:]);d.rectangle([*a,*b],outline=color,width=lw);xx=max(0,min(W-size*1.2,a[0]));yy=max(0,a[1]-size*1.35);d.rectangle((xx,yy,xx+size*1.1,yy+size*1.3),fill=color);d.text((xx+2,yy+1),'A',font=ft,fill='black')
120
+ else:
121
+ end=scale(m['point']);sx=end[0]-W*.12 if end[0]>W*.22 else end[0]+W*.12;sy=max(size*1.8,min(H-size*1.8,end[1]-H*.055));start=(sx,sy);d.line([start,end],fill='black',width=lw+2);d.line([start,end],fill=color,width=lw)
122
+ angle=math.atan2(end[1]-sy,end[0]-sx);L=max(9,W*.013);pts=[end,(end[0]-L*math.cos(angle-.48),end[1]-L*math.sin(angle-.48)),(end[0]-L*math.cos(angle+.48),end[1]-L*math.sin(angle+.48))];d.polygon(pts,fill=color);d.text((sx-size*.7,sy-size*1.2),'A',font=ft,fill=color,stroke_width=1,stroke_fill='black')
123
+ dest.parent.mkdir(parents=True,exist_ok=True);im.save(dest,'JPEG',quality=95,subsampling=0)
124
+ return dict(width=W,height=H,sha256=hashlib.sha256(dest.read_bytes()).hexdigest())
125
+
126
+ def export(root,s,selection,cfg):
127
+ items=[];bytask=collections.defaultdict(list)
128
+ for c in selection:bytask[c['task']].append(c)
129
+ positions=collections.defaultdict(list);rng=random.Random(cfg['seed']+2)
130
+ for task in cfg['target_counts']:
131
+ rows=bytask[task];rng.shuffle(rows)
132
+ for i,c in enumerate(rows):
133
+ qid=f'SCB-{task}-{i+1:04d}';k=len(c['choices']);position=i%k;others=[a for a in c['choices'] if a!=c['answer']];rng.shuffle(others);options=others[:];options.insert(position,c['answer'])
134
+ paths=[];ims=[]
135
+ for j,f in enumerate(c['frames']):
136
+ name=f'{qid}_{j+1}.jpg' if c.get('marker') else f'v{c["video"]:02d}_{f:06d}.jpg';rel=Path('images')/name;dest=root/'release'/rel
137
+ meta=render(c,s.image_path(c['video'],f),dest,cfg);paths.append(str(rel));ims.append(meta)
138
+ r=dict(id=qid,split='test',task=task,family=c['family'],question=c['question'],options=options,answer='ABCD'[position],answer_index=position,answer_text=c['answer'],answer_class=c['answer_class'],images=paths,image_metadata=ims,video_id=f'VID{c["video"]:02d}',frame_ids=c['frames'],source_frame_ids=[f*25 for f in c['frames']],episode_id=c['episode'],query=c['query'],marker=c.get('marker'),tags=c['tags'],candidate_id=c['candidate_id'],quality_status='source_consistency_checked_visual_review_pending' if c.get('marker') else 'source_consistency_and_image_quality_checked',source_evidence=s.source_evidence(c['video'],c['frames']))
139
+ items.append(r)
140
+ write_jsonl(root/'release/benchmark.jsonl',items);write_json(root/'release/config.json',cfg)
141
+ return items
142
+
143
+ def contacts(root,items):
144
+ for task in ['P01','P02','P04','C04','C05','C06','V01','V02','V03','V04']:
145
+ rows=[r for r in items if r['task']==task]
146
+ if task not in ['P01','P02','P04']:
147
+ # Stratified source-review panels, no model outputs are used for selection.
148
+ selected=[]
149
+ for a in sorted({r['answer_class'] for r in rows}):selected += [r for r in rows if r['answer_class']==a][:5]
150
+ rows=selected
151
+ for page in range(math.ceil(len(rows)/12)):
152
+ rr=rows[page*12:(page+1)*12];im=Image.new('RGB',(1440,4*232),(20,20,20));d=ImageDraw.Draw(im)
153
+ for i,r in enumerate(rr):
154
+ x=i%3*480;y=i//3*232;pic=Image.open(root/'release'/r['images'][0]);pic.thumbnail((480,207));im.paste(pic,(x,y+25));label=f'{r["id"]} | {r["answer_text"][:37]} | {r["video_id"]}/{r["frame_ids"][0]}'
155
+ d.text((x+3,y+3),label,font=font(15),fill='white')
156
+ p=root/f'work/review_panels/{task}_{page+1:02d}.jpg';p.parent.mkdir(parents=True,exist_ok=True);im.save(p,quality=90)
157
+
158
+ def main():
159
+ p=argparse.ArgumentParser();p.add_argument('--root',default='/home/ach18533cl/workspace/SceneBench');p.add_argument('--ori',default='/home/ach18533cl/workspace/ori_data');a=p.parse_args();root=Path(a.root);cfg=json.loads((root/'config.json').read_text());s=Sources(a.ori,cfg['test_videos']);sel=Selector(s,root,cfg)
160
+ order=['V03','V04','V02','V01','C05','C04','C06','D04','D03','D02','D05','D01','P02','P04','P01','P03','P05','C01','C02','C03','C07','R01','R02','R03','R04','R05','R06','PR01']
161
+ report={}
162
+ for t in order:report[t]=sel.select_task(t);write_json(root/'work/image_stats.json',sel.stats)
163
+ write_json(root/'work/selection_report.json',dict(tasks=report,rejections=dict(sel.rejected),total=len(sel.selected)))
164
+ write_jsonl(root/'work/selected_candidates.jsonl',sel.selected)
165
+ items=export(root,s,sel.selected,cfg);contacts(root,items);print('EXPORTED',len(items),flush=True)
166
+ if __name__=='__main__':main()
code/validate.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json,collections,hashlib,argparse
2
+ from pathlib import Path
3
+ from common import *
4
+
5
+ def answer_from_evidence(r):
6
+ e=r['source_evidence'];q=r['query'];op=q['op'];ts=[{tuple(t) for t in x['ivt'] if t[1]!='null_verb' and t[2]!='null_target'} for x in e]
7
+ g=e[0]['scene_graph'];o=g['objects'] if g else [];ids={x['component']:i for i,x in enumerate(o)}
8
+ def exact1(x):
9
+ assert len(x)==1,(r['id'],'ambiguous',x)
10
+ return next(iter(x))
11
+ def geo(a,b,p,frame=0):
12
+ oo=e[frame]['scene_graph']['objects']
13
+ if a==b:return False
14
+ axis=0 if p in ['left','right'] else 1;d=oo[a]['center'][axis]-oo[b]['center'][axis]
15
+ assert abs(d)>=(21.5 if axis==0 else 12),(r['id'],'near axis',a,b,p)
16
+ ans=d*(1 if p in ['right','below'] else -1)>0
17
+ if ans:
18
+ rr=e[frame]['scene_graph']['relationships'];assert a in rr.get(p,[[]]*len(oo))[b] and b in rr.get(INV[p],[[]]*len(oo))[a],(r['id'],'spatial edge mismatch',a,b,p)
19
+ return ans
20
+ def quad(a,b=None):
21
+ x,y=o[a]['center'];X,Y=(215,120) if b is None else o[b]['center'];assert abs(x-X)>=21.5 and abs(y-Y)>=12
22
+ if b is not None:geo(a,b,'left' if x<X else 'right');geo(a,b,'above' if y<Y else 'below')
23
+ return ('Upper' if y<Y else 'Lower')+(' left' if x<X else ' right')
24
+ def targets(inst,verb=None,frame=0):return {t[2] for t in ts[frame] if t[0]==inst and (verb is None or t[1]==verb)}
25
+ if op=='phase':return PHASES[e[0]['phase']]
26
+ if op=='object_identity':
27
+ a=o[q['id']]['component'];assert a==q['component'];return title(a)
28
+ if op=='tool_presence':return 'Yes' if e[0]['tools'][TOOLS.index(q['tool'])] else 'No'
29
+ if op=='count_tools':
30
+ ii=[i for i,x in enumerate(o) if x['component']==q['tool'] and x['type']=='instrument'];assert ii==q['ids'];assert bool(ii)==bool(e[0]['tools'][TOOLS.index(q['tool'])]);return str(len(ii))
31
+ if op=='absolute_quadrant':return quad(q['id'])
32
+ if op=='relative_quadrant':return quad(q['subject'],q['reference'])
33
+ if op=='ivt_verb':return GERUND[exact1({t[1] for t in ts[0] if t[0]==q['instrument'] and t[2]==q['target']})]
34
+ if op=='ivt_instrument':return title(exact1({t[0] for t in ts[0] if t[1]==q['verb'] and t[2]==q['target']}))
35
+ if op=='ivt_target':return title(exact1(targets(q['instrument'],q['verb'])))
36
+ if op=='ordered_action_targets':return '('+', '.join(title(exact1(targets(i,v))) for i,v in q['queries'])+')'
37
+ if op=='spatial_tool_target':
38
+ ii=[i for i,x in enumerate(o) if x['type']=='instrument' and x['component'] in INSTRUMENTS and e[0]['tools'][TOOLS.index(x['component'])]]
39
+ inst=o[exact1({i for i in ii if geo(i,q['reference'],q['predicate'])})]['component'];return title(exact1(targets(inst)))
40
+ if op=='action_target_quadrant':return quad(ids[exact1(targets(q['instrument'],q['verb']))],q['reference'])
41
+ if op=='spatial_intersection':
42
+ sets=[{i for i in q['candidate_ids'] if geo(i,ref,p)} for ref,p in zip(q['references'],q['predicates'])];assert all(len(a)>1 for a in sets)
43
+ return title(o[exact1(sets[0]&sets[1])]['component'])
44
+ if op=='action_spatial_intersection':
45
+ aa=targets(q['instrument'],q['verb']);bb={o[i]['component'] for i in q['candidate_ids'] if geo(i,q['reference'],q['predicate'])};assert len(aa)>1 and len(bb)>1;return title(exact1(aa&bb))
46
+ if op=='spatial_count':
47
+ ii=[i for i,x in enumerate(o) if x['type']=='instrument' and x['component'] in INSTRUMENTS];assert set(ii)==set(q['tool_ids'])
48
+ sets=[{i for i in ii if geo(i,ref,p)} for ref,p in zip(q['references'],q['predicates'])];return str(len(sets[0]&sets[1]))
49
+ if op=='spatial_target_instrument':
50
+ ans={t[0] for t in ts[0] if t[2] in ids and geo(ids[t[2]],q['reference'],q['predicate'])};return title(exact1(ans))
51
+ if op=='cvs':
52
+ from generate import CVS_OPTIONS
53
+ k=q['criterion'];score=q['scores'][k] if k<3 else int(sum(q['scores'])>=5);assert e[0]['phase']==1;return CVS_OPTIONS[k][score]
54
+ if op=='temporal_presence':return ' → '.join('Present' if x['tools'][TOOLS.index(q['tool'])] else 'Absent' for x in e)
55
+ if op=='temporal_verb':return ' → '.join(GERUND[exact1({t[1] for t in tt if t[0]==q['instrument'] and t[2]==q['target']})] for tt in ts)
56
+ if op=='temporal_target':return ' → '.join(title(exact1(targets(q['instrument'],q['verb'],f))) for f in range(2))
57
+ if op=='temporal_phase':return ' → '.join(PHASES[x['phase']] for x in e)
58
+ if op=='temporal_spatial':
59
+ aa=[]
60
+ for f in range(2):
61
+ oo=e[f]['scene_graph']['objects'];ii={x['component']:i for i,x in enumerate(oo)};pp=exact1({p for p in q['axis'] if geo(ii[q['instrument']],ii[q['reference']],p,f)});aa.append(pp.capitalize())
62
+ return ' → '.join(aa)
63
+ raise ValueError(op)
64
+
65
+ def main():
66
+ p=argparse.ArgumentParser();p.add_argument('--root',default='/home/ach18533cl/workspace/SceneBench');a=p.parse_args();root=Path(a.root);items=list(read_jsonl(root/'release/benchmark.jsonl'));cfg=json.loads((root/'config.json').read_text());errors=[];counts=collections.Counter();frames=collections.Counter();dynamic=set();positions=collections.defaultdict(collections.Counter);task_answers=collections.defaultdict(collections.Counter);video_counts=collections.defaultdict(collections.Counter)
67
+ assert len({r['id'] for r in items})==len(items)
68
+ for r in items:
69
+ try:
70
+ assert int(r['video_id'][3:]) in cfg['test_videos'];assert r['split']=='test'
71
+ ans=answer_from_evidence(r);assert ans==r['answer_text'],(ans,r['answer_text']);assert len(set(r['options']))==len(r['options']);assert r['options'][r['answer_index']]==ans;assert 'ABCD'[r['answer_index']]==r['answer']
72
+ assert sum(x==ans for x in r['options'])==1
73
+ for img,meta in zip(r['images'],r['image_metadata']):assert hashlib.sha256((root/'release'/img).read_bytes()).hexdigest()==meta['sha256']
74
+ for f,original in zip(r['frame_ids'],r['source_frame_ids']):assert original==f*25;frames[r['video_id'],f]+=1
75
+ if r['task'].startswith('D'):
76
+ assert len(r['images'])==2 and 3<=r['frame_ids'][1]-r['frame_ids'][0]<=10
77
+ for f in r['frame_ids']:assert (r['video_id'],f) not in dynamic;dynamic.add((r['video_id'],f))
78
+ else:assert len(r['images'])==1
79
+ if r['task'] in ['P01','P02']:assert r['marker'] is not None
80
+ counts[r['task']]+=1;positions[r['task']][r['answer']]+=1;task_answers[r['task']][r['answer_class']]+=1;video_counts[r['task']][r['video_id']]+=1
81
+ except Exception as ex:errors.append({'id':r['id'],'error':str(ex)})
82
+ for key in dynamic:
83
+ if frames[key]!=1:errors.append({'frame':key,'error':'dynamic endpoint reused'})
84
+ for key,n in frames.items():
85
+ if n>2:errors.append({'frame':key,'error':'source frame over reuse limit'})
86
+ for t,c in positions.items():
87
+ if max(c.values())-min(c.values())>1:errors.append({'task':t,'error':'answer position imbalance'})
88
+ report=dict(status='pass' if not errors else 'fail',items=len(items),unique_source_frames=len(frames),tasks=dict(counts),answer_positions={k:dict(v) for k,v in positions.items()},answer_classes={k:dict(v) for k,v in task_answers.items()},video_counts={k:dict(v) for k,v in video_counts.items()},errors=errors)
89
+ write_json(root/'release/validation_report.json',report);print(json.dumps({'status':report['status'],'items':len(items),'errors':errors[:30]},ensure_ascii=False),flush=True)
90
+ if errors:raise SystemExit(1)
91
+ if __name__=='__main__':main()
config.json ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "seed": 20260922,
4
+ "test_videos": [
5
+ 2,
6
+ 6,
7
+ 14,
8
+ 23,
9
+ 25,
10
+ 50,
11
+ 51,
12
+ 66,
13
+ 79
14
+ ],
15
+ "target_counts": {
16
+ "P01": 80,
17
+ "P02": 80,
18
+ "P03": 80,
19
+ "P04": 80,
20
+ "P05": 80,
21
+ "R01": 80,
22
+ "R02": 80,
23
+ "R03": 80,
24
+ "R04": 80,
25
+ "R05": 80,
26
+ "R06": 80,
27
+ "C01": 80,
28
+ "C02": 80,
29
+ "C03": 80,
30
+ "C04": 80,
31
+ "C05": 80,
32
+ "C06": 80,
33
+ "C07": 80,
34
+ "PR01": 300,
35
+ "V01": 90,
36
+ "V02": 60,
37
+ "V03": 60,
38
+ "V04": 10,
39
+ "D01": 80,
40
+ "D02": 80,
41
+ "D03": 80,
42
+ "D04": 80,
43
+ "D05": 80
44
+ },
45
+ "cvs_answer_targets": {
46
+ "V01": {
47
+ "0": 32,
48
+ "1": 32,
49
+ "2": 26
50
+ },
51
+ "V02": {
52
+ "0": 27,
53
+ "1": 27,
54
+ "2": 6
55
+ },
56
+ "V03": {
57
+ "0": 28,
58
+ "1": 28,
59
+ "2": 4
60
+ },
61
+ "V04": {
62
+ "No": 6,
63
+ "Yes": 4
64
+ }
65
+ },
66
+ "spatial_margin": 0.05,
67
+ "default_min_spacing_seconds": 10,
68
+ "cvs_min_spacing_seconds": 3,
69
+ "max_questions_per_source_frame": 2,
70
+ "max_export_image_dimension": 1280,
71
+ "model": "qwen/qwen3-vl-32b-instruct",
72
+ "evaluation_protocol": "zero_shot_direct_vqa",
73
+ "hf_repo": "EgoF0102/SceneBench",
74
+ "hf_private": true
75
+ }
curation_report.json ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "initial": 2331,
3
+ "final": 2230,
4
+ "dropped": 101,
5
+ "point_corrections": 18,
6
+ "review": {
7
+ "reviewer": "Codex visual audit; not expert medical adjudication",
8
+ "drop": {
9
+ "SCB-P01-0014": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
10
+ "SCB-P01-0026": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
11
+ "SCB-P01-0034": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
12
+ "SCB-P01-0039": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
13
+ "SCB-P01-0042": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
14
+ "SCB-P01-0045": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
15
+ "SCB-P01-0052": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
16
+ "SCB-P01-0063": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
17
+ "SCB-P01-0065": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
18
+ "SCB-P01-0071": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
19
+ "SCB-P01-0077": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
20
+ "SCB-P02-0003": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
21
+ "SCB-P02-0004": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
22
+ "SCB-P02-0007": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
23
+ "SCB-P02-0009": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
24
+ "SCB-P02-0010": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
25
+ "SCB-P02-0012": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
26
+ "SCB-P02-0014": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
27
+ "SCB-P02-0016": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
28
+ "SCB-P02-0018": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
29
+ "SCB-P02-0023": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
30
+ "SCB-P02-0024": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
31
+ "SCB-P02-0026": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
32
+ "SCB-P02-0028": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
33
+ "SCB-P02-0030": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
34
+ "SCB-P02-0033": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
35
+ "SCB-P02-0034": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
36
+ "SCB-P02-0036": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
37
+ "SCB-P02-0037": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
38
+ "SCB-P02-0039": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
39
+ "SCB-P02-0041": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
40
+ "SCB-P02-0046": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
41
+ "SCB-P02-0050": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
42
+ "SCB-P02-0053": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
43
+ "SCB-P02-0058": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
44
+ "SCB-P02-0060": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
45
+ "SCB-P02-0063": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
46
+ "SCB-P02-0065": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
47
+ "SCB-P02-0070": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
48
+ "SCB-P02-0071": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
49
+ "SCB-P02-0072": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
50
+ "SCB-P02-0076": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
51
+ "SCB-P02-0077": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
52
+ "SCB-P04-0003": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
53
+ "SCB-P04-0005": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
54
+ "SCB-P04-0009": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
55
+ "SCB-P04-0024": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
56
+ "SCB-P04-0028": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
57
+ "SCB-P04-0031": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
58
+ "SCB-P04-0034": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
59
+ "SCB-P04-0036": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
60
+ "SCB-P04-0038": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
61
+ "SCB-P04-0040": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
62
+ "SCB-P04-0043": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
63
+ "SCB-P04-0047": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
64
+ "SCB-P04-0048": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
65
+ "SCB-P04-0055": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
66
+ "SCB-P04-0056": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
67
+ "SCB-P04-0061": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
68
+ "SCB-P04-0063": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
69
+ "SCB-P04-0064": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
70
+ "SCB-P04-0067": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
71
+ "SCB-P04-0068": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
72
+ "SCB-P04-0074": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
73
+ "SCB-P04-0077": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
74
+ "SCB-P04-0080": "Visible ambiguity, incorrect/overlapping marker, duplicate instrument detection, or unclear target.",
75
+ "SCB-C04-0004": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
76
+ "SCB-C04-0008": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
77
+ "SCB-C04-0012": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
78
+ "SCB-C04-0013": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
79
+ "SCB-C04-0023": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
80
+ "SCB-C06-0002": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
81
+ "SCB-C06-0005": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
82
+ "SCB-C06-0008": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
83
+ "SCB-C06-0010": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
84
+ "SCB-C06-0016": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
85
+ "SCB-C06-0019": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
86
+ "SCB-C06-0021": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
87
+ "SCB-C06-0024": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
88
+ "SCB-C06-0029": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
89
+ "SCB-C06-0031": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
90
+ "SCB-C06-0033": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
91
+ "SCB-C06-0035": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
92
+ "SCB-C06-0037": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
93
+ "SCB-C06-0038": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
94
+ "SCB-C06-0040": "Diagnostic overlay shows duplicate/mislocalized objects or an unclear anatomical reference.",
95
+ "SCB-C06-0041": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
96
+ "SCB-C06-0043": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
97
+ "SCB-C06-0044": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
98
+ "SCB-C06-0045": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
99
+ "SCB-C06-0046": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
100
+ "SCB-C06-0047": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
101
+ "SCB-C06-0054": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
102
+ "SCB-C06-0056": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
103
+ "SCB-C06-0058": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
104
+ "SCB-C06-0059": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
105
+ "SCB-C06-0063": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
106
+ "SCB-C06-0066": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
107
+ "SCB-C06-0067": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
108
+ "SCB-C06-0075": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference.",
109
+ "SCB-C06-0078": "Diagnostic overlay shows duplicate/mislocalized objects, missed tools or an unclear anatomical reference."
110
+ },
111
+ "point_patches": {
112
+ "SCB-P02-0002": [
113
+ 135,
114
+ 50
115
+ ],
116
+ "SCB-P02-0013": [
117
+ 165,
118
+ 136
119
+ ],
120
+ "SCB-P02-0015": [
121
+ 110,
122
+ 175
123
+ ],
124
+ "SCB-P02-0020": [
125
+ 120,
126
+ 150
127
+ ],
128
+ "SCB-P02-0029": [
129
+ 345,
130
+ 125
131
+ ],
132
+ "SCB-P02-0031": [
133
+ 145,
134
+ 115
135
+ ],
136
+ "SCB-P02-0044": [
137
+ 165,
138
+ 25
139
+ ],
140
+ "SCB-P02-0048": [
141
+ 340,
142
+ 70
143
+ ],
144
+ "SCB-P02-0051": [
145
+ 240,
146
+ 110
147
+ ],
148
+ "SCB-P02-0056": [
149
+ 335,
150
+ 190
151
+ ],
152
+ "SCB-P02-0059": [
153
+ 325,
154
+ 160
155
+ ],
156
+ "SCB-P02-0064": [
157
+ 150,
158
+ 85
159
+ ],
160
+ "SCB-P02-0066": [
161
+ 310,
162
+ 175
163
+ ],
164
+ "SCB-P02-0067": [
165
+ 135,
166
+ 23
167
+ ],
168
+ "SCB-P02-0069": [
169
+ 195,
170
+ 75
171
+ ],
172
+ "SCB-P02-0074": [
173
+ 230,
174
+ 60
175
+ ],
176
+ "SCB-P02-0080": [
177
+ 151,
178
+ 58
179
+ ],
180
+ "SCB-P02-0075": [
181
+ 185,
182
+ 175
183
+ ]
184
+ },
185
+ "fully_reviewed_tasks": [
186
+ "P01",
187
+ "P02",
188
+ "P04",
189
+ "C06"
190
+ ],
191
+ "notes": "No model correctness or answer text used for curation. Final P02 marker correction completed before official baseline; three P01 API-format smoke checks are archived separately and excluded.",
192
+ "stratified_review_tasks": [
193
+ "C04",
194
+ "C05",
195
+ "V01",
196
+ "V02",
197
+ "V03",
198
+ "V04"
199
+ ]
200
+ },
201
+ "replacements": [
202
+ {
203
+ "id": "SCB-V04-0001",
204
+ "old_candidate_id": "fa3e206275b6f9153ad9",
205
+ "new_candidate_id": "427c3077084d3ed4ee69",
206
+ "frame": 640,
207
+ "reason": "Same-video, late-Calot negative control"
208
+ },
209
+ {
210
+ "id": "SCB-V04-0002",
211
+ "old_candidate_id": "badc69cb8c7bf49a57d1",
212
+ "new_candidate_id": "4deda3330485969c5cfb",
213
+ "frame": 637,
214
+ "reason": "Same-video, late-Calot negative control"
215
+ },
216
+ {
217
+ "id": "SCB-V04-0004",
218
+ "old_candidate_id": "640aef86b3e1e71bfd45",
219
+ "new_candidate_id": "b347c152af3b2bf83ccd",
220
+ "frame": 643,
221
+ "reason": "Same-video, late-Calot negative control"
222
+ }
223
+ ],
224
+ "tasks": {
225
+ "P01": 69,
226
+ "P02": 48,
227
+ "P03": 80,
228
+ "P04": 57,
229
+ "P05": 80,
230
+ "R01": 80,
231
+ "R02": 80,
232
+ "R03": 80,
233
+ "R04": 80,
234
+ "R05": 80,
235
+ "R06": 80,
236
+ "C01": 80,
237
+ "C02": 80,
238
+ "C03": 80,
239
+ "C04": 75,
240
+ "C05": 61,
241
+ "C06": 50,
242
+ "C07": 80,
243
+ "PR01": 300,
244
+ "V01": 90,
245
+ "V02": 60,
246
+ "V03": 60,
247
+ "V04": 9,
248
+ "D01": 80,
249
+ "D02": 71,
250
+ "D03": 80,
251
+ "D04": 80,
252
+ "D05": 80
253
+ },
254
+ "families": {
255
+ "Perception": 334,
256
+ "Relation": 480,
257
+ "Composition": 506,
258
+ "Procedure": 300,
259
+ "CVS": 219,
260
+ "Dynamic": 391
261
+ },
262
+ "scope": "Source-derived reference answers; visual screening by Codex is not expert medical validation. No baseline-model outputs were used to select or edit questions."
263
+ }
data/test-00000-of-00006.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b5fb0c42b97d252ade7d993899e55b5bfb9d8eff3db38d606ecd795c47d2e57
3
+ size 52072544
data/test-00001-of-00006.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b45fd2d755a4cc37a62f9bd85eeeff68a4b528044aaf642f8e99a2b9a8e66f6e
3
+ size 50877324
data/test-00002-of-00006.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41f28650887411c8964307174d9e95d24ef6871ece22d7a6a4328a2032d3f309
3
+ size 51859774
data/test-00003-of-00006.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc6837262a6e988c61c28656e35e6ee70c27c025a34f3af7854655820e1448fd
3
+ size 50892041
data/test-00004-of-00006.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cbe57ddcca7623313e67c77ba23569fa4c64b0d6f42996d5921523b946dc8ab
3
+ size 53319308
data/test-00005-of-00006.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04fb5786a8d6e6f7eba31026de661f6ce248f4043258d74aaaf566dbfd62073b
3
+ size 100299167
dataset_statistics.json ADDED
@@ -0,0 +1,636 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "items": 2230,
3
+ "unique_source_frames": 2435,
4
+ "unique_exported_images": 2463,
5
+ "family_counts": {
6
+ "Perception": 334,
7
+ "Relation": 480,
8
+ "Composition": 506,
9
+ "Procedure": 300,
10
+ "CVS": 219,
11
+ "Dynamic": 391
12
+ },
13
+ "task_counts": {
14
+ "P01": 69,
15
+ "P02": 48,
16
+ "P03": 80,
17
+ "P04": 57,
18
+ "P05": 80,
19
+ "R01": 80,
20
+ "R02": 80,
21
+ "R03": 80,
22
+ "R04": 80,
23
+ "R05": 80,
24
+ "R06": 80,
25
+ "C01": 80,
26
+ "C02": 80,
27
+ "C03": 80,
28
+ "C04": 75,
29
+ "C05": 61,
30
+ "C06": 50,
31
+ "C07": 80,
32
+ "PR01": 300,
33
+ "V01": 90,
34
+ "V02": 60,
35
+ "V03": 60,
36
+ "V04": 9,
37
+ "D01": 80,
38
+ "D02": 71,
39
+ "D03": 80,
40
+ "D04": 80,
41
+ "D05": 80
42
+ },
43
+ "videos": {
44
+ "VID23": 251,
45
+ "VID79": 254,
46
+ "VID66": 245,
47
+ "VID06": 243,
48
+ "VID51": 262,
49
+ "VID50": 241,
50
+ "VID25": 244,
51
+ "VID02": 244,
52
+ "VID14": 246
53
+ },
54
+ "answer_classes": {
55
+ "P01": {
56
+ "clipper": 14,
57
+ "grasper": 10,
58
+ "bipolar": 12,
59
+ "hook": 12,
60
+ "irrigator": 10,
61
+ "scissors": 11
62
+ },
63
+ "P02": {
64
+ "gut": 8,
65
+ "gallbladder": 13,
66
+ "cystic_plate": 7,
67
+ "omentum": 5,
68
+ "liver": 15
69
+ },
70
+ "P03": {
71
+ "No": 40,
72
+ "Yes": 40
73
+ },
74
+ "P04": {
75
+ "1": 21,
76
+ "2": 14,
77
+ "0": 21,
78
+ "3": 1
79
+ },
80
+ "P05": {
81
+ "Lower left": 20,
82
+ "Lower right": 20,
83
+ "Upper left": 20,
84
+ "Upper right": 20
85
+ },
86
+ "R01": {
87
+ "retract": 10,
88
+ "dissect": 10,
89
+ "coagulate": 10,
90
+ "grasp": 10,
91
+ "cut": 10,
92
+ "clip": 10,
93
+ "aspirate": 10,
94
+ "irrigate": 8,
95
+ "pack": 2
96
+ },
97
+ "R02": {
98
+ "clipper": 14,
99
+ "grasper": 13,
100
+ "bipolar": 13,
101
+ "irrigator": 14,
102
+ "hook": 13,
103
+ "scissors": 13
104
+ },
105
+ "R03": {
106
+ "liver": 8,
107
+ "fluid": 7,
108
+ "gut": 8,
109
+ "cystic_plate": 8,
110
+ "cystic_duct": 7,
111
+ "gallbladder": 7,
112
+ "omentum": 8,
113
+ "specimen_bag": 8,
114
+ "cystic_artery": 8,
115
+ "peritoneum": 8,
116
+ "abdominal_wall_cavity": 2,
117
+ "cystic_pedicle": 1
118
+ },
119
+ "R04": {
120
+ "Lower left": 20,
121
+ "Upper left": 20,
122
+ "Upper right": 20,
123
+ "Lower right": 20
124
+ },
125
+ "R05": {
126
+ "Upper left": 20,
127
+ "Lower left": 20,
128
+ "Upper right": 20,
129
+ "Lower right": 20
130
+ },
131
+ "R06": {
132
+ "Lower left": 20,
133
+ "Upper left": 20,
134
+ "Lower right": 20,
135
+ "Upper right": 20
136
+ },
137
+ "C01": {
138
+ "liver|gallbladder": 11,
139
+ "cystic_plate|liver": 1,
140
+ "liver|liver": 11,
141
+ "gallbladder|gallbladder": 11,
142
+ "gallbladder|omentum": 6,
143
+ "gallbladder|cystic_plate": 11,
144
+ "cystic_duct|gallbladder": 1,
145
+ "omentum|omentum": 10,
146
+ "omentum|gallbladder": 7,
147
+ "cystic_plate|gallbladder": 6,
148
+ "gallbladder|gut": 1,
149
+ "gut|omentum": 1,
150
+ "gallbladder|liver": 1,
151
+ "liver|abdominal_wall_cavity": 1,
152
+ "omentum|liver": 1
153
+ },
154
+ "C02": {
155
+ "omentum": 19,
156
+ "gut": 5,
157
+ "gallbladder": 19,
158
+ "liver": 18,
159
+ "cystic_plate": 18,
160
+ "abdominal_wall_cavity": 1
161
+ },
162
+ "C03": {
163
+ "Lower right": 20,
164
+ "Lower left": 20,
165
+ "Upper left": 20,
166
+ "Upper right": 20
167
+ },
168
+ "C04": {
169
+ "omentum": 15,
170
+ "gut": 16,
171
+ "gallbladder": 16,
172
+ "liver": 16,
173
+ "cystic_plate": 12
174
+ },
175
+ "C05": {
176
+ "liver": 23,
177
+ "gallbladder": 22,
178
+ "gut": 5,
179
+ "omentum": 10,
180
+ "cystic_plate": 1
181
+ },
182
+ "C06": {
183
+ "2": 11,
184
+ "1": 15,
185
+ "0": 16,
186
+ "3": 8
187
+ },
188
+ "C07": {
189
+ "hook": 37,
190
+ "grasper": 38,
191
+ "bipolar": 3,
192
+ "scissors": 1,
193
+ "clipper": 1
194
+ },
195
+ "PR01": {
196
+ "3": 50,
197
+ "4": 50,
198
+ "2": 50,
199
+ "1": 50,
200
+ "6": 50,
201
+ "5": 50
202
+ },
203
+ "V01": {
204
+ "1": 32,
205
+ "0": 32,
206
+ "2": 26
207
+ },
208
+ "V02": {
209
+ "0": 27,
210
+ "2": 6,
211
+ "1": 27
212
+ },
213
+ "V03": {
214
+ "1": 28,
215
+ "0": 28,
216
+ "2": 4
217
+ },
218
+ "V04": {
219
+ "No": 6,
220
+ "Yes": 3
221
+ },
222
+ "D01": {
223
+ "Absent → Absent": 20,
224
+ "Absent → Present": 20,
225
+ "Present → Present": 20,
226
+ "Present → Absent": 20
227
+ },
228
+ "D02": {
229
+ "Retracting → Retracting": 9,
230
+ "Dissecting → Dissecting": 9,
231
+ "Coagulating → Coagulating": 9,
232
+ "Coagulating → Dissecting": 4,
233
+ "Dissecting → Retracting": 6,
234
+ "Grasping → Grasping": 9,
235
+ "Packing → Packing": 2,
236
+ "Dissecting → Coagulating": 6,
237
+ "Aspirating → Aspirating": 9,
238
+ "Retracting → Dissecting": 4,
239
+ "Retracting → Coagulating": 1,
240
+ "Irrigating → Irrigating": 1,
241
+ "Irrigating → Retracting": 1,
242
+ "Coagulating → Retracting": 1
243
+ },
244
+ "D03": {
245
+ "Gut → Gut": 3,
246
+ "Specimen bag → Specimen bag": 2,
247
+ "Cystic duct → Cystic plate": 3,
248
+ "Omentum → Liver": 1,
249
+ "Omentum → Gut": 3,
250
+ "Cystic duct → Cystic duct": 3,
251
+ "Gallbladder → Peritoneum": 3,
252
+ "Gallbladder → Cystic plate": 2,
253
+ "Fluid → Fluid": 3,
254
+ "Cystic artery → Cystic duct": 3,
255
+ "Abdominal wall cavity → Abdominal wall cavity": 1,
256
+ "Cystic duct → Omentum": 1,
257
+ "Cystic plate → Gallbladder": 2,
258
+ "Gallbladder → Cystic artery": 1,
259
+ "Liver → Liver": 3,
260
+ "Cystic artery → Cystic artery": 3,
261
+ "Cystic plate → Cystic duct": 2,
262
+ "Gallbladder → Cystic duct": 2,
263
+ "Omentum → Omentum": 3,
264
+ "Peritoneum → Gallbladder": 3,
265
+ "Peritoneum → Peritoneum": 3,
266
+ "Cystic artery → Gallbladder": 2,
267
+ "Cystic duct → Gallbladder": 2,
268
+ "Liver → Gallbladder": 2,
269
+ "Cystic duct → Cystic artery": 2,
270
+ "Gallbladder → Gallbladder": 3,
271
+ "Cystic plate → Cystic plate": 3,
272
+ "Cystic plate → Cystic artery": 3,
273
+ "Cystic artery → Cystic plate": 2,
274
+ "Omentum → Gallbladder": 2,
275
+ "Cystic pedicle → Cystic pedicle": 2,
276
+ "Gallbladder → Liver": 2,
277
+ "Gallbladder → Omentum": 2,
278
+ "Liver → Gut": 1,
279
+ "Specimen bag → Gallbladder": 1,
280
+ "Gut → Gallbladder": 1
281
+ },
282
+ "D04": {
283
+ "Cleaning and coagulation → Cleaning and coagulation": 7,
284
+ "Gallbladder dissection → Cleaning and coagulation": 2,
285
+ "Gallbladder retraction → Gallbladder retraction": 8,
286
+ "Clipping and cutting → Gallbladder dissection": 8,
287
+ "Gallbladder packaging → Gallbladder packaging": 8,
288
+ "Gallbladder packaging → Gallbladder retraction": 4,
289
+ "Clipping and cutting → Clipping and cutting": 7,
290
+ "Gallbladder dissection → Gallbladder packaging": 5,
291
+ "Calot triangle dissection → Calot triangle dissection": 7,
292
+ "Gallbladder dissection → Gallbladder dissection": 7,
293
+ "Gallbladder packaging → Cleaning and coagulation": 5,
294
+ "Cleaning and coagulation → Gallbladder retraction": 4,
295
+ "Calot triangle dissection → Clipping and cutting": 8
296
+ },
297
+ "D05": {
298
+ "Below → Below": 10,
299
+ "Right → Right": 10,
300
+ "Above → Below": 10,
301
+ "Left → Left": 10,
302
+ "Left → Right": 10,
303
+ "Below → Above": 10,
304
+ "Right → Left": 10,
305
+ "Above → Above": 10
306
+ }
307
+ },
308
+ "answer_positions": {
309
+ "P01": {
310
+ "A": 18,
311
+ "B": 17,
312
+ "C": 17,
313
+ "D": 17
314
+ },
315
+ "P02": {
316
+ "A": 12,
317
+ "B": 12,
318
+ "C": 12,
319
+ "D": 12
320
+ },
321
+ "P03": {
322
+ "A": 40,
323
+ "B": 40
324
+ },
325
+ "P04": {
326
+ "A": 15,
327
+ "B": 14,
328
+ "C": 14,
329
+ "D": 14
330
+ },
331
+ "P05": {
332
+ "A": 20,
333
+ "B": 20,
334
+ "C": 20,
335
+ "D": 20
336
+ },
337
+ "R01": {
338
+ "A": 20,
339
+ "B": 20,
340
+ "C": 20,
341
+ "D": 20
342
+ },
343
+ "R02": {
344
+ "A": 20,
345
+ "B": 20,
346
+ "C": 20,
347
+ "D": 20
348
+ },
349
+ "R03": {
350
+ "A": 20,
351
+ "B": 20,
352
+ "C": 20,
353
+ "D": 20
354
+ },
355
+ "R04": {
356
+ "A": 20,
357
+ "B": 20,
358
+ "C": 20,
359
+ "D": 20
360
+ },
361
+ "R05": {
362
+ "A": 20,
363
+ "B": 20,
364
+ "C": 20,
365
+ "D": 20
366
+ },
367
+ "R06": {
368
+ "A": 20,
369
+ "B": 20,
370
+ "C": 20,
371
+ "D": 20
372
+ },
373
+ "C01": {
374
+ "A": 20,
375
+ "B": 20,
376
+ "C": 20,
377
+ "D": 20
378
+ },
379
+ "C02": {
380
+ "A": 20,
381
+ "B": 20,
382
+ "C": 20,
383
+ "D": 20
384
+ },
385
+ "C03": {
386
+ "A": 20,
387
+ "B": 20,
388
+ "C": 20,
389
+ "D": 20
390
+ },
391
+ "C04": {
392
+ "A": 19,
393
+ "B": 19,
394
+ "C": 19,
395
+ "D": 18
396
+ },
397
+ "C05": {
398
+ "A": 16,
399
+ "B": 15,
400
+ "C": 15,
401
+ "D": 15
402
+ },
403
+ "C06": {
404
+ "A": 13,
405
+ "B": 13,
406
+ "C": 12,
407
+ "D": 12
408
+ },
409
+ "C07": {
410
+ "A": 20,
411
+ "B": 20,
412
+ "C": 20,
413
+ "D": 20
414
+ },
415
+ "PR01": {
416
+ "A": 75,
417
+ "B": 75,
418
+ "C": 75,
419
+ "D": 75
420
+ },
421
+ "V01": {
422
+ "A": 30,
423
+ "B": 30,
424
+ "C": 30
425
+ },
426
+ "V02": {
427
+ "A": 20,
428
+ "B": 20,
429
+ "C": 20
430
+ },
431
+ "V03": {
432
+ "A": 20,
433
+ "B": 20,
434
+ "C": 20
435
+ },
436
+ "V04": {
437
+ "A": 5,
438
+ "B": 4
439
+ },
440
+ "D01": {
441
+ "A": 20,
442
+ "B": 20,
443
+ "C": 20,
444
+ "D": 20
445
+ },
446
+ "D02": {
447
+ "A": 18,
448
+ "B": 18,
449
+ "C": 18,
450
+ "D": 17
451
+ },
452
+ "D03": {
453
+ "A": 20,
454
+ "B": 20,
455
+ "C": 20,
456
+ "D": 20
457
+ },
458
+ "D04": {
459
+ "A": 20,
460
+ "B": 20,
461
+ "C": 20,
462
+ "D": 20
463
+ },
464
+ "D05": {
465
+ "A": 20,
466
+ "B": 20,
467
+ "C": 20,
468
+ "D": 20
469
+ }
470
+ },
471
+ "cvs": {
472
+ "V01": {
473
+ "0": {
474
+ "questions": 32,
475
+ "videos": [
476
+ "VID02",
477
+ "VID06",
478
+ "VID14",
479
+ "VID23",
480
+ "VID25",
481
+ "VID50",
482
+ "VID51",
483
+ "VID66",
484
+ "VID79"
485
+ ],
486
+ "segments": 12,
487
+ "label_sources": {
488
+ "explicit_interval": 32
489
+ }
490
+ },
491
+ "1": {
492
+ "questions": 32,
493
+ "videos": [
494
+ "VID06",
495
+ "VID14",
496
+ "VID23",
497
+ "VID25",
498
+ "VID50",
499
+ "VID51",
500
+ "VID66"
501
+ ],
502
+ "segments": 11,
503
+ "label_sources": {
504
+ "explicit_interval": 32
505
+ }
506
+ },
507
+ "2": {
508
+ "questions": 26,
509
+ "videos": [
510
+ "VID02",
511
+ "VID06",
512
+ "VID14",
513
+ "VID23",
514
+ "VID66"
515
+ ],
516
+ "segments": 5,
517
+ "label_sources": {
518
+ "explicit_interval": 26
519
+ }
520
+ }
521
+ },
522
+ "V02": {
523
+ "0": {
524
+ "questions": 27,
525
+ "videos": [
526
+ "VID02",
527
+ "VID06",
528
+ "VID14",
529
+ "VID23",
530
+ "VID25",
531
+ "VID51",
532
+ "VID66",
533
+ "VID79"
534
+ ],
535
+ "segments": 12,
536
+ "label_sources": {
537
+ "explicit_interval": 27
538
+ }
539
+ },
540
+ "1": {
541
+ "questions": 27,
542
+ "videos": [
543
+ "VID50",
544
+ "VID51",
545
+ "VID66"
546
+ ],
547
+ "segments": 6,
548
+ "label_sources": {
549
+ "explicit_interval": 27
550
+ }
551
+ },
552
+ "2": {
553
+ "questions": 6,
554
+ "videos": [
555
+ "VID51"
556
+ ],
557
+ "segments": 2,
558
+ "label_sources": {
559
+ "explicit_interval": 6
560
+ }
561
+ }
562
+ },
563
+ "V03": {
564
+ "0": {
565
+ "questions": 28,
566
+ "videos": [
567
+ "VID02",
568
+ "VID06",
569
+ "VID14",
570
+ "VID23",
571
+ "VID25",
572
+ "VID50",
573
+ "VID51",
574
+ "VID66",
575
+ "VID79"
576
+ ],
577
+ "segments": 11,
578
+ "label_sources": {
579
+ "explicit_interval": 28
580
+ }
581
+ },
582
+ "1": {
583
+ "questions": 28,
584
+ "videos": [
585
+ "VID02",
586
+ "VID06",
587
+ "VID14",
588
+ "VID23",
589
+ "VID25",
590
+ "VID51",
591
+ "VID66",
592
+ "VID79"
593
+ ],
594
+ "segments": 14,
595
+ "label_sources": {
596
+ "explicit_interval": 28
597
+ }
598
+ },
599
+ "2": {
600
+ "questions": 4,
601
+ "videos": [
602
+ "VID66"
603
+ ],
604
+ "segments": 1,
605
+ "label_sources": {
606
+ "explicit_interval": 4
607
+ }
608
+ }
609
+ },
610
+ "V04": {
611
+ "No": {
612
+ "questions": 6,
613
+ "videos": [
614
+ "VID25",
615
+ "VID51",
616
+ "VID66",
617
+ "VID79"
618
+ ],
619
+ "segments": 4,
620
+ "label_sources": {
621
+ "explicit_interval": 6
622
+ }
623
+ },
624
+ "Yes": {
625
+ "questions": 3,
626
+ "videos": [
627
+ "VID66"
628
+ ],
629
+ "segments": 1,
630
+ "label_sources": {
631
+ "explicit_interval": 3
632
+ }
633
+ }
634
+ }
635
+ }
636
+ }
docs/Benchmark说明_20260922.md ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SceneBench v1.0.0:Benchmark 说明
2
+
3
+ 本版本共 **2230 题、6 层、28 个题型**,全部从原始数据重新生成。仅发布 test 集;没有复用旧版 2300 题,也没有另外划主榜或子榜。
4
+
5
+ ## 数据与输入
6
+
7
+ 固定视频:VID02、VID06、VID14、VID23、VID25、VID50、VID51、VID66、VID79。训练和验证数据应继续使用这些测试视频以外的手术,不能按帧把同一测试视频混入训练。
8
+
9
+ 共有 2435 个不同的原始 1 fps 帧、2463 个导出图像文件。P/R/C/PR/V 均为单帧;只有 D 为按时间排序的两帧,间隔 3、5、8 或 10 秒。没有要求生成长时序 graph。
10
+
11
+ 问答使用英语。P03、V04 为二选一;V01–V03 保留原生 0/1/2 三级评分,为三选一;其余题型为四选一。每题只有一个可由完整查询确定的正确选项;R 类若同一查询存在多个动作、主体或目标,就不生成该候选。空间关系将横纵方向合成互斥四象限,避免“左”和“上”同时正确。
12
+
13
+ ## 各层数量
14
+
15
+ | 层 | 目标 | 最终 |
16
+ |---|---:|---:|
17
+ | 感知 | 400 | 334 |
18
+ | 关系 | 480 | 480 |
19
+ | 组合 | 560 | 506 |
20
+ | 流程 | 300 | 300 |
21
+ | CVS | 220 | 219 |
22
+ | 动态 | 400 | 391 |
23
+
24
+ 候选抽样得到 2331 题,图像复核剔除 101 题,修正 18 个箭头落点。C05、D02、V04 在初次抽样时已有候选容量缺口;进一步复核导致 P01/P02/P04/C04/C06 减少。没有用重复题或放宽 GT 唯一性来补齐目标。
25
+
26
+ ## 每个题型的真实问答示例
27
+
28
+ 下列示例均直接来自本次冻结的 benchmark.jsonl。选项顺序、答案与样本 ID 一致。完整证据见同 ID 的 source_evidence、query、marker 字段。
29
+
30
+ ### P01 · 器械定位识别(69 题)
31
+
32
+ 样本 `SCB-P01-0001`;来源 `VID23`,1 fps 帧 `[674]`。
33
+
34
+ What type of instrument is indicated by box A?
35
+
36
+ - A. Clipper
37
+ - B. Grasper
38
+ - C. Scissors
39
+ - D. Hook
40
+
41
+ 正确答案:**A. Clipper**。
42
+
43
+ ### P02 · 解剖结构定位识别(48 题)
44
+
45
+ 样本 `SCB-P02-0001`;来源 `VID50`,1 fps 帧 `[84]`。
46
+
47
+ Which anatomical structure is indicated by arrow A?
48
+
49
+ - A. Gut
50
+ - B. Cystic plate
51
+ - C. Liver
52
+ - D. Gallbladder
53
+
54
+ 正确答案:**A. Gut**。
55
+
56
+ ### P03 · 器械存在性(80 题)
57
+
58
+ 样本 `SCB-P03-0001`;来源 `VID23`,1 fps 帧 `[1438]`。
59
+
60
+ Is a hook visible in this image?
61
+
62
+ - A. No
63
+ - B. Yes
64
+
65
+ 正确答案:**A. No**。
66
+
67
+ ### P04 · 同类器械计数(57 题)
68
+
69
+ 样本 `SCB-P04-0001`;来源 `VID02`,1 fps 帧 `[1142]`。
70
+
71
+ How many separate hook instruments are visible?
72
+
73
+ - A. 1
74
+ - B. 2
75
+ - C. 0
76
+ - D. 3
77
+
78
+ 正确答案:**A. 1**。
79
+
80
+ ### P05 · 器械绝对方位(80 题)
81
+
82
+ 样本 `SCB-P05-0001`;来源 `VID14`,1 fps 帧 `[496]`。
83
+
84
+ In which image quadrant is the center of the grasper bounding box?
85
+
86
+ - A. Lower left
87
+ - B. Upper left
88
+ - C. Lower right
89
+ - D. Upper right
90
+
91
+ 正确答案:**A. Lower left**。
92
+
93
+ ### R01 · 动作识别(80 题)
94
+
95
+ 样本 `SCB-R01-0001`;来源 `VID50`,1 fps 帧 `[620]`。
96
+
97
+ What action is the grasper performing on the gallbladder?
98
+
99
+ - A. Retracting
100
+ - B. Packing
101
+ - C. Irrigating
102
+ - D. Coagulating
103
+
104
+ 正确答案:**A. Retracting**。
105
+
106
+ ### R02 · 动作主体识别(80 题)
107
+
108
+ 样本 `SCB-R02-0001`;来源 `VID66`,1 fps 帧 `[688]`。
109
+
110
+ Which instrument is clipping the cystic duct?
111
+
112
+ - A. Clipper
113
+ - B. Bipolar
114
+ - C. Grasper
115
+ - D. Hook
116
+
117
+ 正确答案:**A. Clipper**。
118
+
119
+ ### R03 · 动作目标识别(80 题)
120
+
121
+ 样本 `SCB-R03-0001`;来源 `VID23`,1 fps 帧 `[1190]`。
122
+
123
+ Which target is the bipolar coagulating?
124
+
125
+ - A. Liver
126
+ - B. Gut
127
+ - C. Cystic plate
128
+ - D. Cystic artery
129
+
130
+ 正确答案:**A. Liver**。
131
+
132
+ ### R04 · 器械相对解剖结构方位(80 题)
133
+
134
+ 样本 `SCB-R04-0001`;来源 `VID06`,1 fps 帧 `[194]`。
135
+
136
+ Where is the center of the omentum bounding box relative to the center of the cystic plate bounding box?
137
+
138
+ - A. Lower left
139
+ - B. Upper right
140
+ - C. Upper left
141
+ - D. Lower right
142
+
143
+ 正确答案:**A. Lower left**。
144
+
145
+ ### R05 · 解剖结构相对器械方位(80 题)
146
+
147
+ 样本 `SCB-R05-0001`;来源 `VID14`,1 fps 帧 `[1096]`。
148
+
149
+ Where is the center of the hook bounding box relative to the center of the omentum bounding box?
150
+
151
+ - A. Upper left
152
+ - B. Upper right
153
+ - C. Lower right
154
+ - D. Lower left
155
+
156
+ 正确答案:**A. Upper left**。
157
+
158
+ ### R06 · 解剖结构之间方位(80 题)
159
+
160
+ 样本 `SCB-R06-0001`;来源 `VID06`,1 fps 帧 `[198]`。
161
+
162
+ Where is the center of the hook bounding box relative to the center of the grasper bounding box?
163
+
164
+ - A. Lower left
165
+ - B. Upper right
166
+ - C. Upper left
167
+ - D. Lower right
168
+
169
+ 正确答案:**A. Lower left**。
170
+
171
+ ### C01 · 两个动作的有序目标组合(80 题)
172
+
173
+ 样本 `SCB-C01-0001`;来源 `VID06`,1 fps 帧 `[1666]`。
174
+
175
+ Which ordered pair gives the structure retracted by the grasper first and the structure dissected by the hook second?
176
+
177
+ - A. (Liver, Gallbladder)
178
+ - B. (Omentum, Omentum)
179
+ - C. (Liver, Omentum)
180
+ - D. (Omentum, Gallbladder)
181
+
182
+ 正确答案:**A. (Liver, Gallbladder)**。
183
+
184
+ ### C02 · 空间筛选器械后查询目标(80 题)
185
+
186
+ 样本 `SCB-C02-0001`;来源 `VID25`,1 fps 帧 `[76]`。
187
+
188
+ Which structure is being acted on by the instrument whose bounding-box center is to the right of the liver center?
189
+
190
+ - A. Omentum
191
+ - B. Cystic plate
192
+ - C. Gallbladder
193
+ - D. Liver
194
+
195
+ 正确答案:**A. Omentum**。
196
+
197
+ ### C03 · 动作目标的相对方位(80 题)
198
+
199
+ 样本 `SCB-C03-0001`;来源 `VID14`,1 fps 帧 `[906]`。
200
+
201
+ Where is the bounding-box center of the structure the grasper is retracting relative to the omentum center?
202
+
203
+ - A. Lower right
204
+ - B. Lower left
205
+ - C. Upper left
206
+ - D. Upper right
207
+
208
+ 正确答案:**A. Lower right**。
209
+
210
+ ### C04 · 两个空间条件的交集(75 题)
211
+
212
+ 样本 `SCB-C04-0001`;来源 `VID06`,1 fps 帧 `[462]`。
213
+
214
+ Which structure has its bounding-box center both above the gut center and to the right of the gallbladder center?
215
+
216
+ - A. Omentum
217
+ - B. Gut
218
+ - C. Cystic plate
219
+ - D. Gallbladder
220
+
221
+ 正确答案:**A. Omentum**。
222
+
223
+ ### C05 · 动作与空间条件的交集(61 题)
224
+
225
+ 样本 `SCB-C05-0001`;来源 `VID66`,1 fps 帧 `[1472]`。
226
+
227
+ Which structure is both retracted by a grasper and has its bounding-box center to the left of the gallbladder center?
228
+
229
+ - A. Liver
230
+ - B. Cystic plate
231
+ - C. Omentum
232
+ - D. Gallbladder
233
+
234
+ 正确答案:**A. Liver**。
235
+
236
+ ### C06 · 两个空间条件下的器械计数(50 题)
237
+
238
+ 样本 `SCB-C06-0001`;来源 `VID66`,1 fps 帧 `[188]`。
239
+
240
+ How many instruments have bounding-box centers both to the left of the gut center and to the left of the gallbladder center?
241
+
242
+ - A. 2
243
+ - B. 0
244
+ - C. 1
245
+ - D. 3
246
+
247
+ 正确答案:**A. 2**。
248
+
249
+ ### C07 · 空间筛选目标后查询器械(80 题)
250
+
251
+ 样本 `SCB-C07-0001`;来源 `VID06`,1 fps 帧 `[1738]`。
252
+
253
+ Which instrument is acting on a structure whose bounding-box center is to the left of the liver center?
254
+
255
+ - A. Hook
256
+ - B. Irrigator
257
+ - C. Grasper
258
+ - D. Clipper
259
+
260
+ 正确答案:**A. Hook**。
261
+
262
+ ### PR01 · 当前手术阶段(300 题)
263
+
264
+ 样本 `SCB-PR01-0001`;来源 `VID66`,1 fps 帧 `[1176]`。
265
+
266
+ Which surgical phase is shown in this image?
267
+
268
+ - A. Gallbladder dissection
269
+ - B. Gallbladder retraction
270
+ - C. Cleaning and coagulation
271
+ - D. Clipping and cutting
272
+
273
+ 正确答案:**A. Gallbladder dissection**。
274
+
275
+ ### V01 · 两结构标准评分(90 题)
276
+
277
+ 样本 `SCB-V01-0001`;来源 `VID14`,1 fps 帧 `[509]`。
278
+
279
+ How clearly are exactly two structures seen connecting to the gallbladder?
280
+
281
+ - A. 1 — Two structures are partly distinguishable, but overlap or limited clarity prevents a clear assessment.
282
+ - B. 0 — Two separate connecting structures cannot be established.
283
+ - C. 2 — Two connecting structures are clearly distinguishable.
284
+
285
+ 正确答案:**A. 1 — Two structures are partly distinguishable, but overlap or limited clarity prevents a clear assessment.**。
286
+
287
+ ### V02 · 胆囊板标准评分(60 题)
288
+
289
+ 样本 `SCB-V02-0001`;来源 `VID06`,1 fps 帧 `[899]`。
290
+
291
+ How clearly is the cystic plate exposed at the lower third of the gallbladder?
292
+
293
+ - A. 0 — The cystic plate is not visible or requires further dissection.
294
+ - B. 2 — It is clearly exposed to approximately the lower third of the gallbladder.
295
+ - C. 1 — It is visible, but exposure, overlap, or viewing angle limits the assessment.
296
+
297
+ 正确答案:**A. 0 — The cystic plate is not visible or requires further dissection.**。
298
+
299
+ ### V03 · 肝胆三角标准评分(60 题)
300
+
301
+ 样本 `SCB-V03-0001`;来源 `VID66`,1 fps 帧 `[583]`。
302
+
303
+ How clearly has the hepatocystic triangle been cleared to reveal its structures?
304
+
305
+ - A. 1 — The triangle is only partly clear or its view remains limited.
306
+ - B. 2 — The triangle is fully cleared and its structures are clearly visible.
307
+ - C. 0 — Tissue or technical limitations prevent assessment of the triangle and its structures.
308
+
309
+ 正确答案:**A. 1 — The triangle is only partly clear or its view remains limited.**。
310
+
311
+ ### V04 · 整体 CVS 是否达到(9 题)
312
+
313
+ 样本 `SCB-V04-0001`;来源 `VID66`,1 fps 帧 `[640]`。
314
+
315
+ Is the critical view of safety (CVS) achieved in this image?
316
+
317
+ - A. No
318
+ - B. Yes
319
+
320
+ 正确答案:**A. No**。
321
+
322
+ ### D01 · 器械存在状态变化(80 题)
323
+
324
+ 样本 `SCB-D01-0001`;来源 `VID25`,1 fps 帧 `[1401, 1404]`。
325
+
326
+ Which pair describes bipolar visibility in frame 1 and frame 2, in that order?
327
+
328
+ - A. Absent → Absent
329
+ - B. Absent → Present
330
+ - C. Present → Present
331
+ - D. Present → Absent
332
+
333
+ 正确答案:**A. Absent → Absent**。
334
+
335
+ ### D02 · 动作状态变化(71 题)
336
+
337
+ 样本 `SCB-D02-0001`;来源 `VID51`,1 fps 帧 `[2169, 2172]`。
338
+
339
+ What is the grasper doing to the gallbladder in frame 1 and frame 2, respectively?
340
+
341
+ - A. Retracting → Retracting
342
+ - B. Dissecting → Dissecting
343
+ - C. Retracting → Dissecting
344
+ - D. Dissecting → Retracting
345
+
346
+ 正确答案:**A. Retracting → Retracting**。
347
+
348
+ ### D03 · 作用目标变化(80 题)
349
+
350
+ 样本 `SCB-D03-0001`;来源 `VID02`,1 fps 帧 `[345, 350]`。
351
+
352
+ Which target is the grasper retracting in frame 1 and frame 2, respectively?
353
+
354
+ - A. Gut → Gut
355
+ - B. Gut → Omentum
356
+ - C. Omentum → Omentum
357
+ - D. Omentum → Gut
358
+
359
+ 正确答案:**A. Gut → Gut**。
360
+
361
+ ### D04 · 手术阶段变化(80 题)
362
+
363
+ 样本 `SCB-D04-0001`;来源 `VID14`,1 fps 帧 `[1631, 1634]`。
364
+
365
+ Which surgical phase is shown in frame 1 and frame 2, respectively?
366
+
367
+ - A. Cleaning and coagulation → Cleaning and coagulation
368
+ - B. Cleaning and coagulation → Calot triangle dissection
369
+ - C. Calot triangle dissection → Cleaning and coagulation
370
+ - D. Calot triangle dissection → Calot triangle dissection
371
+
372
+ 正确答案:**A. Cleaning and coagulation → Cleaning and coagulation**。
373
+
374
+ ### D05 · 空间关系变化(80 题)
375
+
376
+ 样本 `SCB-D05-0001`;来源 `VID02`,1 fps 帧 `[2103, 2106]`。
377
+
378
+ Relative to the liver bounding-box center, is the hook center above or below in frame 1 and frame 2, respectively?
379
+
380
+ - A. Below → Below
381
+ - B. Above → Above
382
+ - C. Below → Above
383
+ - D. Above → Below
384
+
385
+ 正确答案:**A. Below → Below**。
386
+
387
+ ## Ground truth 与可追溯性
388
+
389
+ 原始目录为 `/home/ach18533cl/workspace/ori_data`。
390
+
391
+ - 图像:`CholecT45/data/VIDxx/ffffff.png`。1 fps 帧索引从 0 开始,对应 Cholec80 原始 25 fps 帧号 `25 × f`;对九个视频逐帧验证了该映射。
392
+ - 动作与目标:`CholecT45/triplet/VIDxx.txt` 及 `dict/`。R01–R03、动作组合和动态动作使用真实 IVT;排除 null 动作/目标及完整查询多解。
393
+ - 阶段与器械存在:` Cholec80_labels/labels/{train,val,test}/...pickle`,目录名开头有一个空格。`Tool_gt=None` 视为缺失,不能当作不存在。
394
+ - 空间、类别、实例数:`scene_graph/VIDxx_f.json` 的 `scenes[0]`。保留原始对象、bbox、center 与关系。坐标画布为 430×240。`a in right[b]` 表示 a 在 b 右侧;用坐标和反向边同时验证,不能照 README 中相反方向的文字例子实现。
395
+ - CVS:`Cholec80_CVS/cholec80-CVS.xlsx` 的分段评分,并记录原 Excel 行号和标签来源。现有 VQA 文本没有用来改写旧题或替代证据。
396
+
397
+ 图结构中的 bbox 和部分解剖类别来自自动检测/图生成,不等同于逐帧专家金标准。本版本保证答案可由保存的源标注与确定规则重算,并做了图像质量筛选及分层视觉复核;不能声称每条源标注都经外科专家确认。P01/P02/P04/C06 对全部初选样本做视觉筛查,C04/C05/CVS 做按答案分层抽查。复核发现的明显重复检测、错框、模糊目标已剔除。该边界也适用于评测得分的解释。
398
+
399
+ ## Marker 与图像处理
400
+
401
+ P01 的黄色 A 框和 P02 的黄色 A 箭头已画入实际导出 JPEG,也已嵌入 Hugging Face 的图像字节。框来自源 bbox;箭头指向源 bbox 内经视觉筛查的落点,18 处作了修正(实际列表见 curation_report.json)。没有把答案类别文字写入图像。
402
+
403
+ 按原图宽高分别从 430×240 映射坐标;最长边最多 1280 像素,JPEG quality 95。没有裁剪、翻转或更改时间顺序。原图路径、输出尺寸和 SHA256 均可追溯。诊断用的多框复核图不作为模型输入。
404
+
405
+ ## 重新抽样规则
406
+
407
+ 先建立所有题型的合格候选,再按题型配额轮转,并优先选择不足的答案类和视频,避免高频、易生成题占满。普通候选扫描步长 2 秒,CVS 在有效域逐秒扫描;动态候选检查两个端点的真实标签。PR01 每个有数据的阶段 50 题,Preparation 不在这些 CholecT45 测试帧的有效阶段库存中。
408
+
409
+ 同视频同题型普通题至少间隔 10 秒,CVS 至少 3 秒。每个原始帧最多用于 2 题;动态两帧端点由该动态题独占。同类动作题每个动作持续事件至多取一次。CVS 每个连续同标签区间每题型最多 15 帧,允许区间内多个代表帧;结合亮度、清晰度和 dHash 去重。最终选项答案位置在每个题型内计数最多相差 1。复核后的语义类别分布不强行补齐,实际分布见 dataset_statistics.json。
410
+
411
+ D02 描述的是同一器械类别在同一目标上的端点动作变化;未提供器械实例 tracking ID,所以不把它解释为同一物理实例的连续追踪。动态样本包含稳定与变化情况,单侧上限 60%,稀有变化不足时允许数量缺口。
412
+
413
+ ## CVS 的区间规则与限制
414
+
415
+ 已核对 [Cholec80-CVS 论文](https://www.nature.com/articles/s41597-023-02073-7) 和官方转换脚本:标注区间内所有帧共享区间标签;有效标注域内未覆盖片段默认三项为 0。**不能把最近一次非零标签一直向后填充。** 官方实现本身可在区间内以 5 fps 输出,原来“一段只取一帧”并非数据集要求。
416
+
417
+ 本版本进一步限制在 Calot triangle dissection 阶段且首次 clipping/cutting 之前。区间两端包含在内;多行覆盖且评分冲突的秒被剔除。V01–V03 分别使用原始三级评分;V04 按该数据集规则 `sum(V01,V02,V03) >= 5`,不是要求三项全为 2,也不是独立临床认证。
418
+
419
+ V04 的 3 个阳性问题仅来自 VID66 的 661–675 秒这一个阳性事件;V03 的 2 分同样集中于此。V02 的 2 分仅来自 VID51 的两个区间。这些帧增加视角/遮挡覆盖,不能当成多个独立手术或多个独立阳性事件。已把部分 V04 阴性替换为 VID66 相近手术进度的帧;其余阴性也限制在较晚 Calot,减少容易的阶段线索。
420
+
421
+ | CVS 题型 | 答案类 | 问题数 | 视频数 | 连续标签区间数 |
422
+ |---|---|---:|---:|---:|
423
+ | V01 | 0 | 32 | 9 | 12 |
424
+ | V01 | 1 | 32 | 7 | 11 |
425
+ | V01 | 2 | 26 | 5 | 5 |
426
+ | V02 | 0 | 27 | 8 | 12 |
427
+ | V02 | 1 | 27 | 3 | 6 |
428
+ | V02 | 2 | 6 | 1 | 2 |
429
+ | V03 | 0 | 28 | 9 | 11 |
430
+ | V03 | 1 | 28 | 8 | 14 |
431
+ | V03 | 2 | 4 | 1 | 1 |
432
+ | V04 | No | 6 | 4 | 4 |
433
+ | V04 | Yes | 3 | 1 | 1 |
434
+
435
+ 整体 CVS 阴性不妨碍生成 V01–V03:它仍然可能只有某些标准达到 1 或 2 分。结果应报告每项每分值表现;只有一个独立阳性事件的 V04 不能支持可靠的跨手术敏感度结论。
436
+
437
+ ## 文件与复现
438
+
439
+ - `release/benchmark.jsonl`:全部题目、相对图像路径、GT、原始证据和生成查询。
440
+ - `release/images/`:最终模型输入图像,包含实际 marker。
441
+ - `release/validation_report.json`:逐题重算、唯一性、图像哈希、分集、复用和答案位置检查。
442
+ - `release/curation_report.json`:剔除记录、箭头修正、阴性匹配替换和复核范围。
443
+ - `huggingface/data/test-*.parquet`:嵌入图像字节的便携数据集,可直接 load_dataset。
444
+ - `docs/Benchmark说明_20260922.md`:本说明;评测完成后另写结果分析。
445
+ - `evaluation/`:完整请求协议、原始回答、统计与分析。
446
+
447
+ 随机种子 `20260922`;版本 `1.0.0`;冻结 SHA256 `260d6a03c822f6d80e0eb4b585924e3d1910e39f0503ded056bbb61132276bc6`。
448
+
449
+ ```bash
450
+ .venv/bin/python generate.py
451
+ .venv/bin/python select_render.py
452
+ .venv/bin/python curate.py
453
+ .venv/bin/python validate.py
454
+ .venv/bin/python package_release.py
455
+ .venv/bin/python evaluate_openrouter.py
456
+ ```
457
+
458
+ 复现视觉决策使用 curation.json;不要在已有评测结果后覆盖冻结问题。源数据需另行放在上述 ori_data 路径。依赖见 requirements-lock.txt。
459
+
460
+ ## 发布与许可
461
+
462
+ Hugging Face:`EgoF0102/SceneBench`,本次默认私有仓库。图像和衍生标注遵循源数据的 CC BY-NC-SA 4.0;需保留源数据引用与署名,限非商业用途,衍生共享使用相同许可。引用 Cholec80/EndoNet、CholecT45/Rendezvous、SSG-VQA 与 Cholec80-CVS。
source_policy/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Source-policy verification
2
+
3
+ The accompanying official Cholec80-CVS conversion scripts were checked against the published annotation rules: intervals share one score; uncovered portions of the eligible domain default to zero, rather than carrying a previous nonzero label forward. The original converter samples at 5 fps. SceneBench uses spaced 1 fps timestamps, Calot/pre-first-clipping restrictions and conflict exclusion.
4
+
5
+ Paper: https://www.nature.com/articles/s41597-023-02073-7
6
+
7
+ SSG-VQA source README is included for original authors, citations, license and source-generation description. Its spatial direction example must be interpreted using the actual object coordinates and inverse-edge checks described in the SceneBench documentation.
source_policy/cvs_annotations_2_labels_verified.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import math
3
+ import numpy as np
4
+ import pandas as pd
5
+
6
+
7
+ annotations_file_name = "surgeons_annotations"
8
+ truncation_ratio = 0.85
9
+ target_fps = 5
10
+
11
+
12
+ video_fps = 25
13
+ doctors_annotations = pd.read_excel(f"../data/{annotations_file_name}.xlsx", engine='openpyxl')
14
+ result_path = f"../data/{annotations_file_name.split('.')[0]}"
15
+ index_data = pd.read_csv("../results/videos_frames_index.csv")
16
+
17
+ for video_tag, video_data in doctors_annotations.groupby("video"):
18
+ print(f"Processing video {video_tag}")
19
+ video_name = f"video{str(video_tag).zfill(2)}"
20
+ valid_frames = index_data[index_data["video_name"] == video_name]["final_frame"].iloc[0]
21
+
22
+ video_result = pd.DataFrame(columns=["video_name", "image", "two_structures_score", "cystic_plate_score",
23
+ "hc_triangle_score"])
24
+ video_result["image"] = list(range(valid_frames + 1))
25
+ video_result[["video_name", "two_structures_score", "cystic_plate_score",
26
+ "hc_triangle_score"]] = [video_name, 0, 0, 0]
27
+
28
+ for i, row in video_data.iterrows():
29
+ if row["two_structures"] + row["cystic_plate"] + row["hepatocystic_triangle"] > 0:
30
+ tag = [row["two_structures"], row["cystic_plate"], row["hepatocystic_triangle"]]
31
+ initial_frame = int(row["initial_minute"] * 60 * video_fps + row["initial_second"] * video_fps)
32
+ final_frame = int(row["final_minute"] * 60 * video_fps + row["final_second"] * video_fps)
33
+ assert initial_frame <= video_result.shape[0], "ERROR: initial frame is out of range"
34
+ if final_frame >= video_result.shape[0]:
35
+ final_frame = valid_frames
36
+ for frame_number in range(initial_frame, final_frame+1):
37
+ video_result.loc[frame_number, ["two_structures_score",
38
+ "cystic_plate_score", "hc_triangle_score"]] = tag
39
+
40
+ # truncate videos so we get rid off of a bunch of zeros
41
+
42
+ initial_second = math.floor(video_result.shape[0] * truncation_ratio / 25)
43
+ initial_frame = initial_second * 25
44
+ video_result = video_result[initial_frame:]
45
+
46
+ # Reduce FPS by randomly extracting frames
47
+
48
+ chunk_list = list()
49
+ for offset in range(0, video_result.shape[0], video_fps):
50
+ chunk = video_result[offset:offset+video_fps]
51
+ chunk.reset_index(inplace=True, drop=True)
52
+ replace_flag = False
53
+ if chunk.shape[0] < target_fps:
54
+ replace_flag = True
55
+ index = list(np.random.choice(chunk.shape[0], target_fps, replace=replace_flag))
56
+ chunk = chunk.iloc[index]
57
+ chunk_list.append(chunk)
58
+
59
+ video_result = pd.concat(chunk_list)
60
+ video_result.to_csv(os.path.join(result_path, f"{video_name}.csv"), index=False)
source_policy/cvs_get_valid_frames_verified.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import utils
3
+ import pandas as pd
4
+
5
+ """
6
+ DESCRIPTION:
7
+
8
+ This script extracts the index of the last valid frame, which corresponds with the last frame
9
+ before the Clipping and Cutting Phase.
10
+ """
11
+
12
+ dataset_path = utils.get_dataset_path()
13
+ dataset_path = os.path.join(dataset_path, "phase_annotations")
14
+ annotations_path = os.listdir(dataset_path)
15
+ result = pd.DataFrame(columns=["video_name", "final_frame"])
16
+ for annotation in annotations_path:
17
+ print(f"Proccesing video {annotation}")
18
+ data = pd.read_csv(os.path.join(dataset_path, annotation), sep='\t')
19
+ frame_index = data[data["Phase"] == "ClippingCutting"]["Frame"].iloc[0] - 1
20
+ result.loc[len(result)] = [annotation.split('-')[0], frame_index]
21
+
22
+ result.to_csv("../results/videos_frames_index.csv", index=False)
source_policy/ssgvqa_readme.md ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ <a href="http://camma.u-strasbg.fr/">
3
+ <img src="asset/camma_logo.png" width="30%">
4
+ </a>
5
+ </div>
6
+
7
+
8
+ # **Advancing Surgical VQA with Scene Graph Knowledge**
9
+ _Kun Yuan, Manasi Kattel, Joel, L. Lavanchy, Nassir Navab, [Vinkle Srivastav](https://vinkle.github.io/), Nicolas Padoy_, 2023
10
+
11
+ <div align="center">
12
+ <img src="asset/ssg-vqa.jpg" width="100%">
13
+ </a>
14
+ </div>
15
+
16
+ # $$\color{Blue} SSG-VQA \space Dataset $$
17
+
18
+ This repo contains an open-source PyTorch code and the dataset for the paper [Advancing Surgical VQA with Scene Graph Knowledge](https://arxiv.org/abs/2312.10251)
19
+
20
+
21
+
22
+ [![arXiv](https://img.shields.io/badge/arxiv-2312.10251-red)](https://arxiv.org/abs/2312.10251)
23
+
24
+ ## Introduction
25
+
26
+ The modern operating room is becoming increasingly complex, requiring innovative intra-operative support systems. While the focus of surgical data science has largely been on video analysis, integrating surgical computer vision with natural language capabilities is emerging as a necessity. Our work aims to advance Visual Question Answering (VQA) in the surgical context with scene graph knowledge, addressing two main challenges in the current surgical VQA systems: removing question-condition bias in the surgical VQA dataset and incorporating scene-aware reasoning in the surgical VQA model design.
27
+
28
+
29
+ First, we propose a **S**urgical **S**cene **G**raph-based dataset, SSG-VQA, generated by employing segmentation and detection models on publicly available datasets. We build surgical scene graphs using spatial and action information of instruments and anatomies. These graphs are fed into a question engine, generating diverse QA pairs. Our SSG-VQA dataset provides a more complex, diverse, geometrically grounded, unbiased, and surgical action-oriented dataset compared to existing surgical VQA datasets. We then propose SSG-VQA-Net, a novel surgical VQA model incorporating a lightweight Scene-embedded Interaction Module (SIM), which integrates geometric scene knowledge in the VQA model design by employing cross-attention between the textual and the scene features.
30
+
31
+ Our comprehensive analysis of the SSG-VQA dataset shows that SSG-VQA-Net outperforms existing methods across different question types and complexities. We highlight that the primary limitation in the current surgical VQA systems is the lack of scene knowledge to answer complex queries.
32
+
33
+ #### SSG-VQA dataset generation pipeline
34
+ <!-- ![pipeline](./asset/pipeline.png) -->
35
+ <img src="./asset/ssg_qa_dataset.gif" alt="SSG-QA_Net" width="800"/>
36
+
37
+ #### SG-VQA-Net
38
+ <img src="./asset/model.png" alt="SSG-QA_Net" width="800"/>
39
+
40
+
41
+ # Get started
42
+
43
+ ## Installation
44
+ ## Environment
45
+ You need to have a Anaconda3 installed for the setup. We developed the code on Python 3.8, PyTorch 1.7.1, and CUDA 10.2.
46
+ ```bash
47
+ $ git clone https://github.com/CAMMA-public/SSG-VQA.git
48
+ $ conda env create -f environment.yml
49
+ $ conda activate ssgvqa
50
+ ```
51
+
52
+ ## Downloads
53
+ #### Question-answer pairs
54
+ Download question-answer pairs from from our S3 server and unzip it into **./data/qa_txt** folder
55
+ ```bash
56
+ (ssgvqa)$ wget https://s3.unistra.fr/camma_public/github/ssg-qa/ssg-qa.zip
57
+ (ssgvqa)$ unzip ssg-qa.zip -d ./data/qa_txt
58
+ ```
59
+ #### Scene Graphs
60
+ We provide the scene graph in **scene_graph_ssgqa.zip** in .json format.
61
+ The relationship is a list, where index is the subject of this relationship, and the index is the target, e.g., 'left': [[1, 2], [], []], means the 0 object is to the left of object 1 and 2.
62
+ The image size that bounding boxes are corresponded to is (240, 430)
63
+ #### Visual features
64
+ - (Recommended) Download the features to train and test the model from our S3 server and unzip the files into folder **./data/visual_feats** folder
65
+
66
+ ```bash
67
+ (ssgvqa)$ wget https://s3.unistra.fr/camma_public/github/ssg-qa/cropped_images.zip
68
+ (ssgvqa)$ wget https://s3.unistra.fr/camma_public/github/ssg-qa/roi_yolo_coord.zip
69
+ (ssgvqa)$ unzip cropped_images.zip -d ./data/visual_feats
70
+ (ssgvqa)$ unzip roi_yolo_coord.zip -d ./data/visual_feats
71
+ ```
72
+
73
+ - Or, create the features by yourself using the images from public [CholecT45](http://camma.u-strasbg.fr/datasets):
74
+ ```bash
75
+ (ssgvqa)$ python utils/feat_extract_visual.py
76
+ (ssgvqa)$ python utils/feature_extract_roi.py
77
+ ```
78
+ ### Model weights for the SSG-VQA-Net
79
+ Place the model weights in the [`checkpoints`](./checkpoints) directory
80
+ | Model | Model Weights |
81
+ | :----------: | :-----: |
82
+ | SSG-VQA-Net| [download](https://s3.unistra.fr/camma_public/github/ssg-qa/ssg-qa-net.pth.tar) |
83
+
84
+ #### Directory structure should look as follows.
85
+
86
+ ```
87
+ # checkpoints: this is the folder in which all the weights are saved.
88
+ # data: this is the folder in which in which all the the pre-extracted features are saved.
89
+
90
+ ├──checkpoints
91
+ │ ├── experiment1
92
+ │ │ └── Best.pth.tar
93
+ │ └── ...
94
+ ├──data
95
+ │ ├── visual_feats
96
+ │ │ ├── cropped_images
97
+ │ │ │ └── VID01
98
+ │ │ │ └���─ vqa
99
+ │ │ │ └── img_features
100
+ │ │ │ └── 1x1
101
+ │ │ │ └── 000001.hdf5
102
+ │ │ │ └── ...
103
+ │ │ ├── roi_yolo_coord
104
+ │ │ │ └── VID01
105
+ │ │ │ └── labels
106
+ │ │ │ └── vqa
107
+ │ │ │ └── img_features
108
+ │ │ │ └── roi
109
+ │ │ │ └── 000001.hdf5
110
+ │ │ │ └── ...
111
+ │ └── qa_txt
112
+ │ └── VID01
113
+ │ └── 1.txt
114
+ │ └── ...
115
+ └── ...
116
+ ```
117
+
118
+
119
+
120
+ ## Training
121
+
122
+ ```bash
123
+ (ssgvqa)$ python train.py --validate=False
124
+ ```
125
+
126
+
127
+ ## Evaluation
128
+ ```bash
129
+ (ssgvqa)$ python test.py --validate=True --checkpoint checkpoints/ssg-qa-net.pth.tar
130
+ ```
131
+ Evaluate the performance in different complexity: set --dataset_type=ssg-qa-roi-analysis
132
+ ```bash
133
+ (ssgvqa)$ python test.py --validate=True --dataset_type=ssg-qa-roi-analysis --checkpoint checkpoints/ssg-qa-net.pth.tar
134
+ ```
135
+
136
+ ## Results
137
+ The SSG-VQA dataset is a multi-class classification-based VQA dataset, we report the F1-Score in the table.
138
+ | Model | Query Object | Query Attribute | Existence | Counting | Zero-hop | One-hop | Single-and | Mean |
139
+ |------:|:------:|:------:|:------:|:------:|:------:|:------:|:------:| :------:|
140
+ | SSG-VQA-Net | 49.4 | 60.0 | 75.8 | 28.6 | 58.2 | 52.4 | 38.4 | 54.9 |
141
+
142
+
143
+ ## Citing SSG-VQA
144
+ This dataset could only be generated thanks to the continuous support from our clinical partners. If you use this dataset, you are kindly requested to
145
+ cite the work that led to the generation of this dataset:
146
+ ```bibtex
147
+ @article{yuan2024advancing,
148
+ title={Advancing surgical VQA with scene graph knowledge},
149
+ author={Yuan, Kun and Kattel, Manasi and Lavanchy, Jo{\"e}l L and Navab, Nassir and Srivastav, Vinkle and Padoy, Nicolas},
150
+ journal={International Journal of Computer Assisted Radiology and Surgery},
151
+ pages={1--9},
152
+ year={2024},
153
+ publisher={Springer}
154
+ }
155
+ ```
156
+ [[`Download PDF`](https://arxiv.org/pdf/2312.10251.pdf)]
157
+
158
+
159
+
160
+ ## Other works that have contributed to the generation of SSG-VQA dataset
161
+ ```bibtex
162
+ @article{nwoye2022rendezvous,
163
+ title={Rendezvous: Attention mechanisms for the recognition of surgical action triplets in endoscopic videos},
164
+ author={Nwoye, Chinedu Innocent and Yu, Tong and Gonzalez, Cristians and Seeliger, Barbara and Mascagni, Pietro and Mutter, Didier and Marescaux, Jacques and Padoy, Nicolas},
165
+ journal={Medical Image Analysis},
166
+ volume={78},
167
+ pages={102433},
168
+ year={2022},
169
+ publisher={Elsevier}
170
+ }
171
+ ```
172
+ [[`Download PDF`](https://arxiv.org/pdf/2109.03223.pdf)]
173
+
174
+ ```bibtex
175
+ @article{twinanda2016endonet,
176
+ title={Endonet: a deep architecture for recognition tasks on laparoscopic videos},
177
+ author={Twinanda, Andru P and Shehata, Sherif and Mutter, Didier and Marescaux, Jacques and De Mathelin, Michel and Padoy, Nicolas},
178
+ journal={IEEE transactions on medical imaging},
179
+ volume={36},
180
+ number={1},
181
+ pages={86--97},
182
+ year={2016},
183
+ publisher={IEEE}
184
+ }
185
+ ```
186
+ [[`Download PDF`](https://arxiv.org/pdf/1602.03012.pdf)]
187
+
188
+ ```bibtex
189
+ @inproceedings{jin2018tool,
190
+ title={Tool detection and operative skill assessment in surgical videos using region-based convolutional neural networks},
191
+ author={Jin, Amy and Yeung, Serena and Jopling, Jeffrey and Krause, Jonathan and Azagury, Dan and Milstein, Arnold and Fei-Fei, Li},
192
+ booktitle={2018 IEEE winter conference on applications of computer vision (WACV)},
193
+ pages={691--699},
194
+ year={2018},
195
+ organization={IEEE}
196
+ }
197
+ ```
198
+ [[`Download PDF`](https://arxiv.org/pdf/1802.08774.pdf)]
199
+
200
+
201
+ ```bibtex
202
+ @article{hong2020cholecseg8k,
203
+ title={Cholecseg8k: a semantic segmentation dataset for laparoscopic cholecystectomy based on cholec80},
204
+ author={Hong, W-Y and Kao, C-L and Kuo, Y-H and Wang, J-R and Chang, W-L and Shih, C-S},
205
+ journal={arXiv preprint arXiv:2012.12453},
206
+ year={2020}
207
+ }
208
+ ```
209
+ [[`Download PDF`](https://arxiv.org/pdf/2012.12453.pdf)]
210
+
211
+
212
+ ## License
213
+ This code, models, and datasets are available for non-commercial scientific research purposes as defined in the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/). By downloading and using this code you agree to the terms in the [LICENSE](LICENSE). Third-party codes are subject to their respective licenses.
214
+
215
+ By downloading and using this repo or dataset, you agree on these terms and conditions.
216
+
217
+ ## Acknowledgement
218
+ This work has received funding from the European Union (ERC, CompSURG, 101088553). Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union or the European
219
+ Research Council. Neither the European Union nor the granting authority can be held responsible for them. This work was also partially supported by French state funds managed by the ANR under Grants ANR-20-CHIA-0029-01 and ANR-10-IAHU-02.
220
+
221
+ ## CONTACT
222
+ This dataset was generated by the research group CAMMA: http://camma.u-strasbg.fr/. Any updates regarding this dataset can be found here: http://camma.u-strasbg.fr/datasets. Any questions regarding the dataset can be sent to kyuan@unistra.fr or srivastav@unistra.fr
validation_report.json ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "status": "pass",
3
+ "items": 2230,
4
+ "unique_source_frames": 2435,
5
+ "tasks": {
6
+ "P01": 69,
7
+ "P02": 48,
8
+ "P03": 80,
9
+ "P04": 57,
10
+ "P05": 80,
11
+ "R01": 80,
12
+ "R02": 80,
13
+ "R03": 80,
14
+ "R04": 80,
15
+ "R05": 80,
16
+ "R06": 80,
17
+ "C01": 80,
18
+ "C02": 80,
19
+ "C03": 80,
20
+ "C04": 75,
21
+ "C05": 61,
22
+ "C06": 50,
23
+ "C07": 80,
24
+ "PR01": 300,
25
+ "V01": 90,
26
+ "V02": 60,
27
+ "V03": 60,
28
+ "V04": 9,
29
+ "D01": 80,
30
+ "D02": 71,
31
+ "D03": 80,
32
+ "D04": 80,
33
+ "D05": 80
34
+ },
35
+ "answer_positions": {
36
+ "P01": {
37
+ "A": 18,
38
+ "B": 17,
39
+ "C": 17,
40
+ "D": 17
41
+ },
42
+ "P02": {
43
+ "A": 12,
44
+ "B": 12,
45
+ "C": 12,
46
+ "D": 12
47
+ },
48
+ "P03": {
49
+ "A": 40,
50
+ "B": 40
51
+ },
52
+ "P04": {
53
+ "A": 15,
54
+ "B": 14,
55
+ "C": 14,
56
+ "D": 14
57
+ },
58
+ "P05": {
59
+ "A": 20,
60
+ "B": 20,
61
+ "C": 20,
62
+ "D": 20
63
+ },
64
+ "R01": {
65
+ "A": 20,
66
+ "B": 20,
67
+ "C": 20,
68
+ "D": 20
69
+ },
70
+ "R02": {
71
+ "A": 20,
72
+ "B": 20,
73
+ "C": 20,
74
+ "D": 20
75
+ },
76
+ "R03": {
77
+ "A": 20,
78
+ "B": 20,
79
+ "C": 20,
80
+ "D": 20
81
+ },
82
+ "R04": {
83
+ "A": 20,
84
+ "B": 20,
85
+ "C": 20,
86
+ "D": 20
87
+ },
88
+ "R05": {
89
+ "A": 20,
90
+ "B": 20,
91
+ "C": 20,
92
+ "D": 20
93
+ },
94
+ "R06": {
95
+ "A": 20,
96
+ "B": 20,
97
+ "C": 20,
98
+ "D": 20
99
+ },
100
+ "C01": {
101
+ "A": 20,
102
+ "B": 20,
103
+ "C": 20,
104
+ "D": 20
105
+ },
106
+ "C02": {
107
+ "A": 20,
108
+ "B": 20,
109
+ "C": 20,
110
+ "D": 20
111
+ },
112
+ "C03": {
113
+ "A": 20,
114
+ "B": 20,
115
+ "C": 20,
116
+ "D": 20
117
+ },
118
+ "C04": {
119
+ "A": 19,
120
+ "B": 19,
121
+ "C": 19,
122
+ "D": 18
123
+ },
124
+ "C05": {
125
+ "A": 16,
126
+ "B": 15,
127
+ "C": 15,
128
+ "D": 15
129
+ },
130
+ "C06": {
131
+ "A": 13,
132
+ "B": 13,
133
+ "C": 12,
134
+ "D": 12
135
+ },
136
+ "C07": {
137
+ "A": 20,
138
+ "B": 20,
139
+ "C": 20,
140
+ "D": 20
141
+ },
142
+ "PR01": {
143
+ "A": 75,
144
+ "B": 75,
145
+ "C": 75,
146
+ "D": 75
147
+ },
148
+ "V01": {
149
+ "A": 30,
150
+ "B": 30,
151
+ "C": 30
152
+ },
153
+ "V02": {
154
+ "A": 20,
155
+ "B": 20,
156
+ "C": 20
157
+ },
158
+ "V03": {
159
+ "A": 20,
160
+ "B": 20,
161
+ "C": 20
162
+ },
163
+ "V04": {
164
+ "A": 5,
165
+ "B": 4
166
+ },
167
+ "D01": {
168
+ "A": 20,
169
+ "B": 20,
170
+ "C": 20,
171
+ "D": 20
172
+ },
173
+ "D02": {
174
+ "A": 18,
175
+ "B": 18,
176
+ "C": 18,
177
+ "D": 17
178
+ },
179
+ "D03": {
180
+ "A": 20,
181
+ "B": 20,
182
+ "C": 20,
183
+ "D": 20
184
+ },
185
+ "D04": {
186
+ "A": 20,
187
+ "B": 20,
188
+ "C": 20,
189
+ "D": 20
190
+ },
191
+ "D05": {
192
+ "A": 20,
193
+ "B": 20,
194
+ "C": 20,
195
+ "D": 20
196
+ }
197
+ },
198
+ "answer_classes": {
199
+ "P01": {
200
+ "clipper": 14,
201
+ "grasper": 10,
202
+ "bipolar": 12,
203
+ "hook": 12,
204
+ "irrigator": 10,
205
+ "scissors": 11
206
+ },
207
+ "P02": {
208
+ "gut": 8,
209
+ "gallbladder": 13,
210
+ "cystic_plate": 7,
211
+ "omentum": 5,
212
+ "liver": 15
213
+ },
214
+ "P03": {
215
+ "No": 40,
216
+ "Yes": 40
217
+ },
218
+ "P04": {
219
+ "1": 21,
220
+ "2": 14,
221
+ "0": 21,
222
+ "3": 1
223
+ },
224
+ "P05": {
225
+ "Lower left": 20,
226
+ "Lower right": 20,
227
+ "Upper left": 20,
228
+ "Upper right": 20
229
+ },
230
+ "R01": {
231
+ "retract": 10,
232
+ "dissect": 10,
233
+ "coagulate": 10,
234
+ "grasp": 10,
235
+ "cut": 10,
236
+ "clip": 10,
237
+ "aspirate": 10,
238
+ "irrigate": 8,
239
+ "pack": 2
240
+ },
241
+ "R02": {
242
+ "clipper": 14,
243
+ "grasper": 13,
244
+ "bipolar": 13,
245
+ "irrigator": 14,
246
+ "hook": 13,
247
+ "scissors": 13
248
+ },
249
+ "R03": {
250
+ "liver": 8,
251
+ "fluid": 7,
252
+ "gut": 8,
253
+ "cystic_plate": 8,
254
+ "cystic_duct": 7,
255
+ "gallbladder": 7,
256
+ "omentum": 8,
257
+ "specimen_bag": 8,
258
+ "cystic_artery": 8,
259
+ "peritoneum": 8,
260
+ "abdominal_wall_cavity": 2,
261
+ "cystic_pedicle": 1
262
+ },
263
+ "R04": {
264
+ "Lower left": 20,
265
+ "Upper left": 20,
266
+ "Upper right": 20,
267
+ "Lower right": 20
268
+ },
269
+ "R05": {
270
+ "Upper left": 20,
271
+ "Lower left": 20,
272
+ "Upper right": 20,
273
+ "Lower right": 20
274
+ },
275
+ "R06": {
276
+ "Lower left": 20,
277
+ "Upper left": 20,
278
+ "Lower right": 20,
279
+ "Upper right": 20
280
+ },
281
+ "C01": {
282
+ "liver|gallbladder": 11,
283
+ "cystic_plate|liver": 1,
284
+ "liver|liver": 11,
285
+ "gallbladder|gallbladder": 11,
286
+ "gallbladder|omentum": 6,
287
+ "gallbladder|cystic_plate": 11,
288
+ "cystic_duct|gallbladder": 1,
289
+ "omentum|omentum": 10,
290
+ "omentum|gallbladder": 7,
291
+ "cystic_plate|gallbladder": 6,
292
+ "gallbladder|gut": 1,
293
+ "gut|omentum": 1,
294
+ "gallbladder|liver": 1,
295
+ "liver|abdominal_wall_cavity": 1,
296
+ "omentum|liver": 1
297
+ },
298
+ "C02": {
299
+ "omentum": 19,
300
+ "gut": 5,
301
+ "gallbladder": 19,
302
+ "liver": 18,
303
+ "cystic_plate": 18,
304
+ "abdominal_wall_cavity": 1
305
+ },
306
+ "C03": {
307
+ "Lower right": 20,
308
+ "Lower left": 20,
309
+ "Upper left": 20,
310
+ "Upper right": 20
311
+ },
312
+ "C04": {
313
+ "omentum": 15,
314
+ "gut": 16,
315
+ "gallbladder": 16,
316
+ "liver": 16,
317
+ "cystic_plate": 12
318
+ },
319
+ "C05": {
320
+ "liver": 23,
321
+ "gallbladder": 22,
322
+ "gut": 5,
323
+ "omentum": 10,
324
+ "cystic_plate": 1
325
+ },
326
+ "C06": {
327
+ "2": 11,
328
+ "1": 15,
329
+ "0": 16,
330
+ "3": 8
331
+ },
332
+ "C07": {
333
+ "hook": 37,
334
+ "grasper": 38,
335
+ "bipolar": 3,
336
+ "scissors": 1,
337
+ "clipper": 1
338
+ },
339
+ "PR01": {
340
+ "3": 50,
341
+ "4": 50,
342
+ "2": 50,
343
+ "1": 50,
344
+ "6": 50,
345
+ "5": 50
346
+ },
347
+ "V01": {
348
+ "1": 32,
349
+ "0": 32,
350
+ "2": 26
351
+ },
352
+ "V02": {
353
+ "0": 27,
354
+ "2": 6,
355
+ "1": 27
356
+ },
357
+ "V03": {
358
+ "1": 28,
359
+ "0": 28,
360
+ "2": 4
361
+ },
362
+ "V04": {
363
+ "No": 6,
364
+ "Yes": 3
365
+ },
366
+ "D01": {
367
+ "Absent → Absent": 20,
368
+ "Absent → Present": 20,
369
+ "Present → Present": 20,
370
+ "Present → Absent": 20
371
+ },
372
+ "D02": {
373
+ "Retracting → Retracting": 9,
374
+ "Dissecting → Dissecting": 9,
375
+ "Coagulating → Coagulating": 9,
376
+ "Coagulating → Dissecting": 4,
377
+ "Dissecting → Retracting": 6,
378
+ "Grasping → Grasping": 9,
379
+ "Packing → Packing": 2,
380
+ "Dissecting → Coagulating": 6,
381
+ "Aspirating → Aspirating": 9,
382
+ "Retracting → Dissecting": 4,
383
+ "Retracting → Coagulating": 1,
384
+ "Irrigating → Irrigating": 1,
385
+ "Irrigating → Retracting": 1,
386
+ "Coagulating → Retracting": 1
387
+ },
388
+ "D03": {
389
+ "Gut → Gut": 3,
390
+ "Specimen bag → Specimen bag": 2,
391
+ "Cystic duct → Cystic plate": 3,
392
+ "Omentum → Liver": 1,
393
+ "Omentum → Gut": 3,
394
+ "Cystic duct → Cystic duct": 3,
395
+ "Gallbladder → Peritoneum": 3,
396
+ "Gallbladder → Cystic plate": 2,
397
+ "Fluid → Fluid": 3,
398
+ "Cystic artery → Cystic duct": 3,
399
+ "Abdominal wall cavity → Abdominal wall cavity": 1,
400
+ "Cystic duct → Omentum": 1,
401
+ "Cystic plate → Gallbladder": 2,
402
+ "Gallbladder → Cystic artery": 1,
403
+ "Liver → Liver": 3,
404
+ "Cystic artery → Cystic artery": 3,
405
+ "Cystic plate → Cystic duct": 2,
406
+ "Gallbladder → Cystic duct": 2,
407
+ "Omentum → Omentum": 3,
408
+ "Peritoneum → Gallbladder": 3,
409
+ "Peritoneum → Peritoneum": 3,
410
+ "Cystic artery → Gallbladder": 2,
411
+ "Cystic duct → Gallbladder": 2,
412
+ "Liver → Gallbladder": 2,
413
+ "Cystic duct → Cystic artery": 2,
414
+ "Gallbladder → Gallbladder": 3,
415
+ "Cystic plate → Cystic plate": 3,
416
+ "Cystic plate → Cystic artery": 3,
417
+ "Cystic artery → Cystic plate": 2,
418
+ "Omentum → Gallbladder": 2,
419
+ "Cystic pedicle → Cystic pedicle": 2,
420
+ "Gallbladder → Liver": 2,
421
+ "Gallbladder → Omentum": 2,
422
+ "Liver → Gut": 1,
423
+ "Specimen bag → Gallbladder": 1,
424
+ "Gut → Gallbladder": 1
425
+ },
426
+ "D04": {
427
+ "Cleaning and coagulation → Cleaning and coagulation": 7,
428
+ "Gallbladder dissection → Cleaning and coagulation": 2,
429
+ "Gallbladder retraction → Gallbladder retraction": 8,
430
+ "Clipping and cutting → Gallbladder dissection": 8,
431
+ "Gallbladder packaging → Gallbladder packaging": 8,
432
+ "Gallbladder packaging → Gallbladder retraction": 4,
433
+ "Clipping and cutting → Clipping and cutting": 7,
434
+ "Gallbladder dissection → Gallbladder packaging": 5,
435
+ "Calot triangle dissection → Calot triangle dissection": 7,
436
+ "Gallbladder dissection → Gallbladder dissection": 7,
437
+ "Gallbladder packaging → Cleaning and coagulation": 5,
438
+ "Cleaning and coagulation → Gallbladder retraction": 4,
439
+ "Calot triangle dissection → Clipping and cutting": 8
440
+ },
441
+ "D05": {
442
+ "Below → Below": 10,
443
+ "Right → Right": 10,
444
+ "Above → Below": 10,
445
+ "Left → Left": 10,
446
+ "Left → Right": 10,
447
+ "Below → Above": 10,
448
+ "Right → Left": 10,
449
+ "Above → Above": 10
450
+ }
451
+ },
452
+ "video_counts": {
453
+ "P01": {
454
+ "VID23": 8,
455
+ "VID79": 9,
456
+ "VID66": 8,
457
+ "VID06": 8,
458
+ "VID51": 8,
459
+ "VID50": 8,
460
+ "VID25": 7,
461
+ "VID02": 6,
462
+ "VID14": 7
463
+ },
464
+ "P02": {
465
+ "VID50": 7,
466
+ "VID02": 3,
467
+ "VID79": 6,
468
+ "VID25": 6,
469
+ "VID66": 3,
470
+ "VID14": 5,
471
+ "VID51": 5,
472
+ "VID23": 7,
473
+ "VID06": 6
474
+ },
475
+ "P03": {
476
+ "VID23": 8,
477
+ "VID66": 9,
478
+ "VID02": 9,
479
+ "VID79": 9,
480
+ "VID06": 9,
481
+ "VID25": 9,
482
+ "VID14": 9,
483
+ "VID50": 9,
484
+ "VID51": 9
485
+ },
486
+ "P04": {
487
+ "VID02": 9,
488
+ "VID25": 7,
489
+ "VID06": 3,
490
+ "VID14": 8,
491
+ "VID79": 5,
492
+ "VID23": 9,
493
+ "VID66": 7,
494
+ "VID50": 6,
495
+ "VID51": 3
496
+ },
497
+ "P05": {
498
+ "VID14": 9,
499
+ "VID23": 9,
500
+ "VID79": 8,
501
+ "VID50": 9,
502
+ "VID51": 9,
503
+ "VID66": 9,
504
+ "VID02": 9,
505
+ "VID06": 9,
506
+ "VID25": 9
507
+ },
508
+ "R01": {
509
+ "VID50": 9,
510
+ "VID06": 9,
511
+ "VID79": 8,
512
+ "VID66": 9,
513
+ "VID23": 9,
514
+ "VID02": 9,
515
+ "VID25": 9,
516
+ "VID51": 9,
517
+ "VID14": 9
518
+ },
519
+ "R02": {
520
+ "VID66": 9,
521
+ "VID25": 9,
522
+ "VID06": 9,
523
+ "VID79": 9,
524
+ "VID02": 9,
525
+ "VID23": 9,
526
+ "VID50": 8,
527
+ "VID14": 9,
528
+ "VID51": 9
529
+ },
530
+ "R03": {
531
+ "VID23": 9,
532
+ "VID79": 8,
533
+ "VID14": 9,
534
+ "VID25": 9,
535
+ "VID51": 9,
536
+ "VID02": 9,
537
+ "VID66": 9,
538
+ "VID50": 9,
539
+ "VID06": 9
540
+ },
541
+ "R04": {
542
+ "VID06": 8,
543
+ "VID66": 9,
544
+ "VID51": 9,
545
+ "VID02": 9,
546
+ "VID23": 9,
547
+ "VID25": 9,
548
+ "VID14": 9,
549
+ "VID79": 9,
550
+ "VID50": 9
551
+ },
552
+ "R05": {
553
+ "VID14": 9,
554
+ "VID50": 9,
555
+ "VID51": 9,
556
+ "VID23": 9,
557
+ "VID79": 9,
558
+ "VID02": 9,
559
+ "VID06": 8,
560
+ "VID25": 9,
561
+ "VID66": 9
562
+ },
563
+ "R06": {
564
+ "VID06": 8,
565
+ "VID23": 9,
566
+ "VID50": 9,
567
+ "VID66": 9,
568
+ "VID51": 9,
569
+ "VID25": 9,
570
+ "VID14": 9,
571
+ "VID79": 9,
572
+ "VID02": 9
573
+ },
574
+ "C01": {
575
+ "VID06": 10,
576
+ "VID14": 9,
577
+ "VID50": 8,
578
+ "VID02": 8,
579
+ "VID23": 8,
580
+ "VID25": 9,
581
+ "VID66": 9,
582
+ "VID79": 9,
583
+ "VID51": 10
584
+ },
585
+ "C02": {
586
+ "VID25": 9,
587
+ "VID66": 9,
588
+ "VID79": 9,
589
+ "VID14": 9,
590
+ "VID23": 9,
591
+ "VID06": 9,
592
+ "VID02": 9,
593
+ "VID51": 9,
594
+ "VID50": 8
595
+ },
596
+ "C03": {
597
+ "VID14": 9,
598
+ "VID23": 9,
599
+ "VID50": 9,
600
+ "VID06": 9,
601
+ "VID66": 8,
602
+ "VID51": 9,
603
+ "VID02": 9,
604
+ "VID79": 9,
605
+ "VID25": 9
606
+ },
607
+ "C04": {
608
+ "VID06": 9,
609
+ "VID50": 8,
610
+ "VID79": 7,
611
+ "VID66": 9,
612
+ "VID51": 9,
613
+ "VID25": 8,
614
+ "VID14": 8,
615
+ "VID23": 9,
616
+ "VID02": 8
617
+ },
618
+ "C05": {
619
+ "VID66": 3,
620
+ "VID51": 12,
621
+ "VID14": 6,
622
+ "VID79": 15,
623
+ "VID23": 7,
624
+ "VID25": 4,
625
+ "VID02": 7,
626
+ "VID06": 5,
627
+ "VID50": 2
628
+ },
629
+ "C06": {
630
+ "VID66": 5,
631
+ "VID25": 6,
632
+ "VID79": 7,
633
+ "VID06": 9,
634
+ "VID23": 3,
635
+ "VID50": 5,
636
+ "VID02": 7,
637
+ "VID14": 4,
638
+ "VID51": 4
639
+ },
640
+ "C07": {
641
+ "VID06": 10,
642
+ "VID66": 10,
643
+ "VID02": 10,
644
+ "VID25": 8,
645
+ "VID14": 10,
646
+ "VID79": 9,
647
+ "VID23": 9,
648
+ "VID51": 10,
649
+ "VID50": 4
650
+ },
651
+ "PR01": {
652
+ "VID66": 33,
653
+ "VID14": 34,
654
+ "VID23": 33,
655
+ "VID02": 33,
656
+ "VID06": 33,
657
+ "VID50": 32,
658
+ "VID25": 33,
659
+ "VID79": 35,
660
+ "VID51": 34
661
+ },
662
+ "V01": {
663
+ "VID14": 10,
664
+ "VID02": 9,
665
+ "VID25": 10,
666
+ "VID79": 9,
667
+ "VID66": 9,
668
+ "VID06": 10,
669
+ "VID50": 10,
670
+ "VID51": 9,
671
+ "VID23": 14
672
+ },
673
+ "V02": {
674
+ "VID06": 4,
675
+ "VID25": 5,
676
+ "VID14": 4,
677
+ "VID51": 16,
678
+ "VID50": 15,
679
+ "VID02": 4,
680
+ "VID79": 4,
681
+ "VID23": 4,
682
+ "VID66": 4
683
+ },
684
+ "V03": {
685
+ "VID66": 7,
686
+ "VID51": 6,
687
+ "VID25": 7,
688
+ "VID06": 7,
689
+ "VID14": 7,
690
+ "VID02": 7,
691
+ "VID50": 6,
692
+ "VID23": 7,
693
+ "VID79": 6
694
+ },
695
+ "V04": {
696
+ "VID66": 6,
697
+ "VID25": 1,
698
+ "VID51": 1,
699
+ "VID79": 1
700
+ },
701
+ "D01": {
702
+ "VID25": 9,
703
+ "VID06": 9,
704
+ "VID23": 8,
705
+ "VID66": 9,
706
+ "VID02": 9,
707
+ "VID79": 9,
708
+ "VID14": 9,
709
+ "VID50": 9,
710
+ "VID51": 9
711
+ },
712
+ "D02": {
713
+ "VID51": 9,
714
+ "VID14": 8,
715
+ "VID23": 8,
716
+ "VID79": 9,
717
+ "VID25": 8,
718
+ "VID06": 7,
719
+ "VID50": 7,
720
+ "VID02": 8,
721
+ "VID66": 7
722
+ },
723
+ "D03": {
724
+ "VID02": 9,
725
+ "VID51": 9,
726
+ "VID79": 9,
727
+ "VID14": 9,
728
+ "VID23": 9,
729
+ "VID25": 8,
730
+ "VID66": 9,
731
+ "VID50": 9,
732
+ "VID06": 9
733
+ },
734
+ "D04": {
735
+ "VID14": 9,
736
+ "VID79": 9,
737
+ "VID25": 9,
738
+ "VID50": 8,
739
+ "VID02": 8,
740
+ "VID23": 10,
741
+ "VID51": 9,
742
+ "VID66": 9,
743
+ "VID06": 9
744
+ },
745
+ "D05": {
746
+ "VID02": 9,
747
+ "VID25": 9,
748
+ "VID51": 9,
749
+ "VID23": 9,
750
+ "VID79": 9,
751
+ "VID50": 9,
752
+ "VID14": 9,
753
+ "VID06": 8,
754
+ "VID66": 9
755
+ }
756
+ },
757
+ "errors": []
758
+ }