Download parse_utils/detectron2/tracking/utils.py from tigger13/fastfit: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/tigger13/fastfit/resolve/main/parse_utils/detectron2/tracking/utils.py
- Command line
-
hf download hf://spaces/tigger13/fastfit/parse_utils/detectron2/tracking/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/tigger13/fastfit/resolve/main/parse_utils/detectron2/tracking/utils.py
1.1 kB
| #!/usr/bin/env python3 | |
| import numpy as np | |
| from typing import List | |
| from ..structures import Instances | |
| def create_prediction_pairs( | |
| instances: Instances, | |
| prev_instances: Instances, | |
| iou_all: np.ndarray, | |
| threshold: float = 0.5, | |
| ) -> List: | |
| """ | |
| Args: | |
| instances: predictions from current frame | |
| prev_instances: predictions from previous frame | |
| iou_all: 2D numpy array containing iou for each bbox pair | |
| threshold: below the threshold, doesn't consider the pair of bbox is valid | |
| Return: | |
| List of bbox pairs | |
| """ | |
| bbox_pairs = [] | |
| for i in range(len(instances)): | |
| for j in range(len(prev_instances)): | |
| if iou_all[i, j] < threshold: | |
| continue | |
| bbox_pairs.append( | |
| { | |
| "idx": i, | |
| "prev_idx": j, | |
| "prev_id": prev_instances.ID[j], | |
| "IoU": iou_all[i, j], | |
| "prev_period": prev_instances.ID_period[j], | |
| } | |
| ) | |
| return bbox_pairs | |
| LARGE_COST_VALUE = 100000 | |