forked from HQU-gxy/CVTH3PE
feat: Implement AffinityResult class and optimize camera affinity matrix calculation
- Added a new `AffinityResult` class to encapsulate the results of affinity computations, including the affinity matrix, trackings, and their respective indices. - Introduced a vectorized implementation of `calculate_camera_affinity_matrix_jax` to enhance performance by leveraging JAX's capabilities, replacing the previous double-for-loop approach. - Updated tests in `test_affinity.py` to include parameterized benchmarks for comparing the performance of the new vectorized method against the naive implementation, ensuring accuracy and efficiency.
This commit is contained in:
34
affinity_result.py
Normal file
34
affinity_result.py
Normal file
@ -0,0 +1,34 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Sequence
|
||||
|
||||
from playground import Tracking
|
||||
from beartype.typing import Sequence, Mapping
|
||||
from jaxtyping import jaxtyped, Float, Int
|
||||
from jax import Array
|
||||
|
||||
|
||||
@dataclass
|
||||
class AffinityResult:
|
||||
"""
|
||||
Result of affinity computation between trackings and detections.
|
||||
"""
|
||||
|
||||
matrix: Float[Array, "T D"]
|
||||
"""
|
||||
Affinity matrix between trackings and detections.
|
||||
"""
|
||||
|
||||
trackings: Sequence[Tracking]
|
||||
"""
|
||||
Trackings used to compute the affinity matrix.
|
||||
"""
|
||||
|
||||
indices_T: Sequence[int]
|
||||
"""
|
||||
Indices of the trackings that were used to compute the affinity matrix.
|
||||
"""
|
||||
|
||||
indices_D: Sequence[int]
|
||||
"""
|
||||
Indices of the detections that were used to compute the affinity matrix.
|
||||
"""
|
||||
Reference in New Issue
Block a user