Datasets:

Modalities:
Image
Text
Formats:
webdataset
ArXiv:
Libraries:
Datasets
WebDataset
License:
zxooh46@uni-tuebingen.de
Add video eval
a5ab8f0
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 video"
)
args = parser.parse_args()
try:
with open("videos_gt.json", 'r', encoding='utf-8') as f:
videos_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 video, annots in preds.items():
if videos_gt.get(video, None) is None:
print(f'{video} not present in GT')
continue
for frame, point in annots.items(): #point: (x,y)
if videos_gt[video].get(frame, None) is None:
print(f'Frame {frame} in {video} not present in GT')
continue
total+=1
GT_box = videos_gt[video].get(frame)
if point_in_box(*point, *GT_box):
hits+=1
print(f"Total: {total}, hits: {hits}")
print(f'Pointwise-Acc: {hits/total:.3f}')
if __name__ == "__main__":
main()