Datasets:
zxooh46@uni-tuebingen.de
commited on
Commit
·
eedc72a
1
Parent(s):
c40aa4a
Frame Eval
Browse files- .gitignore +2 -0
- evaluation/frames/eval.py +55 -0
- evaluation/frames/frames_gt.json +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.ipynb_checkpoints/
|
| 2 |
+
**/.ipynb_checkpoints/**
|
evaluation/frames/eval.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import json
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
def point_in_xywh(px, py, x, y, w, h):
|
| 7 |
+
return (x <= px < x + w) and (y <= py < y + h)
|
| 8 |
+
|
| 9 |
+
def main():
|
| 10 |
+
|
| 11 |
+
parser = argparse.ArgumentParser()
|
| 12 |
+
|
| 13 |
+
parser.add_argument(
|
| 14 |
+
"--predictions", type=str, required=True, help="Path to json file with predictions for each clip"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
args = parser.parse_args()
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
with open("frames_gt.json", 'r', encoding='utf-8') as f:
|
| 21 |
+
frames_gt = json.load(f)
|
| 22 |
+
|
| 23 |
+
with open(args.predictions, 'r', encoding='utf-8') as f:
|
| 24 |
+
preds = json.load(f)
|
| 25 |
+
except FileNotFoundError as e:
|
| 26 |
+
print(f"File not found: {e.filename}")
|
| 27 |
+
sys.exit(1)
|
| 28 |
+
|
| 29 |
+
except json.JSONDecodeError as e:
|
| 30 |
+
print(f"Invalid JSON in file: {e}")
|
| 31 |
+
sys.exit(1)
|
| 32 |
+
|
| 33 |
+
except Exception as e:
|
| 34 |
+
print(f"Unexpected error: {e}")
|
| 35 |
+
sys.exit(1)
|
| 36 |
+
|
| 37 |
+
total = 0
|
| 38 |
+
hits = 0
|
| 39 |
+
|
| 40 |
+
for frame, coords in preds.items():
|
| 41 |
+
if frames_gt.get(frame, None) is None:
|
| 42 |
+
print(f'{frame} not present in GT')
|
| 43 |
+
continue
|
| 44 |
+
|
| 45 |
+
total+=1
|
| 46 |
+
GT_box = frames_gt[frame]
|
| 47 |
+
if point_in_xywh(*coords, *GT_box):
|
| 48 |
+
hits+=1
|
| 49 |
+
|
| 50 |
+
print(f"Total: {total}, hits: {hits}")
|
| 51 |
+
print(f'Pointwise-Acc: {hits/total:.3f}')
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
main()
|
| 55 |
+
|
evaluation/frames/frames_gt.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|