Skip to content

Commit c27332e

Browse files
author
Hakan Ardo
committed
codabench
1 parent 439f6b4 commit c27332e

5 files changed

Lines changed: 48 additions & 0 deletions

File tree

codabench/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime
2+
RUN pip install sskit scipy xtcocotools numpy==1.26.4

codabench/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t hakanardo/codabench:synloc .
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command: python3 scoring.py
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import json
2+
from pathlib import Path
3+
from xtcocotools.coco import COCO
4+
from sskit.coco import LocSimCOCOeval
5+
6+
7+
reference_dir = Path('/app/input/ref')
8+
prediction_dir = Path('/app/input/res')
9+
score_dir = Path('/app/output')
10+
11+
with open(prediction_dir / 'metadata.json') as fd:
12+
metadata = json.load(fd)
13+
14+
def eval(tau, suffix):
15+
coco = COCO(reference_dir / 'gt.json')
16+
coco_det = coco.loadRes(str(prediction_dir / "results.json"))
17+
coco_eval = LocSimCOCOeval(coco, coco_det, 'bbox')
18+
19+
coco_eval.params.useSegm = None
20+
coco_eval.params.score_threshold = metadata['score_threshold']
21+
if 'position_from_keypoint_index' in metadata:
22+
coco_eval.params.position_from_keypoint_index = metadata['position_from_keypoint_index']
23+
coco_eval.locsim_tau = tau
24+
25+
coco_eval.evaluate()
26+
coco_eval.accumulate()
27+
coco_eval.summarize()
28+
29+
map_locsim = coco_eval.stats[0]
30+
precision, recall, f1, score_threshold, frame_accuracy = coco_eval.stats[12:]
31+
return {
32+
'mAP-LocSim' + suffix: map_locsim,
33+
'Precision' + suffix: precision,
34+
'Recall' + suffix: recall,
35+
'F1' + suffix: f1,
36+
'FrameAcc' + suffix: frame_accuracy,
37+
}
38+
39+
scores = eval(1, '')
40+
scores.update(eval(5, '(t=5)'))
41+
42+
with open(score_dir / 'scores.json', 'w') as fd:
43+
json.dump(scores, fd)

codabench/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run -ti -v `pwd`/app:/app -v `pwd`/scoring_program:/workspace hakanardo/codabench:synloc python scoring.py

0 commit comments

Comments
 (0)