From c058d8284ab0bbd0e69e87819d1a8fd85645c719 Mon Sep 17 00:00:00 2001 From: Cubevoid <52008334+Cubevoid@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:53:08 -0400 Subject: [PATCH 1/2] Limit IoU to 50 frames --- src/scripts/dataset_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/dataset_stats.py b/src/scripts/dataset_stats.py index e83f51c..0abc5ae 100644 --- a/src/scripts/dataset_stats.py +++ b/src/scripts/dataset_stats.py @@ -59,7 +59,7 @@ def main(game: str) -> None: # Calculate IoU between FastSAM and SAM bboxes iou = calculate_iou(objects_sam, objects_fastsam).squeeze(-1) num_obj = np.maximum(obj_per_frame_sam, obj_per_frame_fastsam) # per frame - ious = [np.mean(iou[i, : num_obj[i]]) for i in range(num_frames)] + ious = [np.mean(iou[i, : num_obj[i]]) for i in range(min(num_frames, 50))] # Make new plot of IoUs plt.figure() plt.plot(ious, label="Mean IoU") From b4b32e669c248baf63f74201e67ad69387c84dcd Mon Sep 17 00:00:00 2001 From: Cubevoid <52008334+Cubevoid@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:01:03 -0400 Subject: [PATCH 2/2] Fix linting --- src/scripts/dataset_stats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/dataset_stats.py b/src/scripts/dataset_stats.py index 0abc5ae..e8d31de 100644 --- a/src/scripts/dataset_stats.py +++ b/src/scripts/dataset_stats.py @@ -6,14 +6,14 @@ from src.data_collection.data_loader import DataLoader -def calculate_iou(boxes1, boxes2): +def calculate_iou(boxes1: npt.NDArray, boxes2: npt.NDArray) -> npt.NDArray: """ Calculate IoU (Intersection over Union) between corresponding bounding boxes. boxes1 and boxes2 should have the format (T, O, 4), where T is the number of timesteps, O is the number of objects, and 4 represents (x2, y2, x1, y1). """ - x1_1, y1_1, x2_1, y2_1 = np.split(boxes1, 4, axis=-1) - x1_2, y1_2, x2_2, y2_2 = np.split(boxes2, 4, axis=-1) + x1_1, y1_1, x2_1, y2_1 = np.split(boxes1, 4, axis=-1) # pylint: disable=unbalanced-tuple-unpacking + x1_2, y1_2, x2_2, y2_2 = np.split(boxes2, 4, axis=-1) # pylint: disable=unbalanced-tuple-unpacking x1_1, x2_1 = np.minimum(x1_1, x2_1), np.maximum(x1_1, x2_1) y1_1, y2_1 = np.minimum(y1_1, y2_1), np.maximum(y1_1, y2_1) x1_2, x2_2 = np.minimum(x1_2, x2_2), np.maximum(x1_2, x2_2)