Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
VlSomers committed Feb 13, 2024
2 parents 473001a + e21d9f7 commit decdbec
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tracklab/wrappers/eval/trackeval_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json
import os
import zipfile

import numpy as np
import pandas as pd
import logging
Expand Down Expand Up @@ -48,7 +50,7 @@ def run(self, tracker_state):
f"Tracking predictions saved in {self.trackeval_dataset_name} format in {pred_save_path}")

if tracker_state.detections_gt is None or len(tracker_state.detections_gt) == 0:
log.info(
log.warning(
f"Stopping evaluation because the current split ({self.eval_set}) has no ground truth detections.")
return

Expand Down Expand Up @@ -111,6 +113,7 @@ def save_in_soccernet_format(detections: pd.DataFrame,
bbox_column_for_eval="bbox_ltwh",
save_classes=False,
is_ground_truth=False,
save_zip=True
):
if is_ground_truth:
return
Expand All @@ -120,6 +123,7 @@ def save_in_soccernet_format(detections: pd.DataFrame,
camera_metadata = soccernet_encoding(image_metadatas.copy(), supercategory="camera")
pitch_metadata = soccernet_encoding(image_metadatas.copy(), supercategory="pitch")
predictions = pd.concat([detections, camera_metadata, pitch_metadata], ignore_index=True)
zf_save_path = save_path.parents[1] / f"{save_path.parent.name}.zip"
for id, video in video_metadatas.iterrows():
file_path = save_path / f"{video['name']}.json"
video_predictions_df = predictions[predictions["video_id"] == str(id)].copy()
Expand All @@ -128,6 +132,9 @@ def save_in_soccernet_format(detections: pd.DataFrame,
video_predictions = [{k: int(v) if k == 'track_id' else v for k, v in m.items() if np.all(pd.notna(v))} for m in video_predictions_df.to_dict(orient="records")]
with file_path.open("w") as fp:
json.dump({"predictions": video_predictions}, fp, indent=2)
if save_zip:
with zipfile.ZipFile(zf_save_path, "a", compression=zipfile.ZIP_DEFLATED) as zf:
zf.write(file_path, arcname=f"{save_path.name}/{file_path.name}")


def transform_bbox_image(row):
Expand Down

0 comments on commit decdbec

Please sign in to comment.