Datasets:

Modalities:
Image
Text
Formats:
webdataset
ArXiv:
Libraries:
Datasets
WebDataset
License:
zxooh46@uni-tuebingen.de
Refined eval
0268768
import argparse
import json
from pathlib import Path
import sys
def point_in_box(px, py, x_min, y_min, x_max, y_max):
return (x_min <= px < x_max) and (y_min <= py < y_max)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--predictions", type=str, required=True, help="Path to json file with predictions for each clip"
)
args = parser.parse_args()
try:
with open("frames_gt.json", 'r', encoding='utf-8') as f:
frames_gt = json.load(f)
with open(args.predictions, 'r', encoding='utf-8') as f:
preds = json.load(f)
except FileNotFoundError as e:
print(f"File not found: {e.filename}")
sys.exit(1)
except json.JSONDecodeError as e:
print(f"Invalid JSON in file: {e}")
sys.exit(1)
except Exception as e:
print(f"Unexpected error: {e}")
sys.exit(1)
total = 0
hits = 0
for frame, coords in preds.items():
if frames_gt.get(frame, None) is None:
print(f'{frame} not present in GT')
continue
total+=1
GT_box = frames_gt[frame]
if point_in_box(*coords, *GT_box):
hits+=1
print(f"Total: {total}, hits: {hits}")
print(f'Pointwise-Acc: {hits/total:.3f}')
if __name__ == "__main__":
main()