Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOTA revisited #181

Merged
merged 57 commits into from
Jul 9, 2024
Merged

MOTA revisited #181

merged 57 commits into from
Jul 9, 2024

Conversation

nikk-nikaznan
Copy link
Collaborator

@nikk-nikaznan nikk-nikaznan commented Jun 5, 2024

I am trying to add more definition to what we consider as ID switches. This PR consider ID switch as a crab been assigned a new ID (re-ID)

  • This is a bug : The old way of getting the ID switch is by finding the symmetric_difference between two list. The problem with this if we have prev_id = [1, 2, 3] and current_id = [1, 2, 4] the n_switches =2. The new approach will be 1.

After some help from @sfmig and @samcunliffe, this is currently what we have:

  • We create a dict to map the ground_truth ID to tracked ID in every frame.

    • during count_identity_switches we have prev_frame_id_map and current_frame_id_map.
    • for each gt ID and tracked ID of current frame, we retrieve the tracked ID from previous frame that associated with a particular ground truth ID in current frame.
    • we also do the inverse, we retrieve the ground truth ID from previous frame that associate with a particular predicted ID in current frame.
    • we only check once, if the previous ID either from ground truth or prediction exist, if they exist, we check if the value is the same.
  • Some changes for the test -- feel free to play around with the value in the test to see any other possibility.

@codecov-commenter
Copy link

codecov-commenter commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 33 lines in your changes missing coverage. Please review.

Project coverage is 46.16%. Comparing base (ff59d84) to head (1d45dd6).

Files Patch % Lines
crabs/tracker/evaluate_tracker.py 80.43% 18 Missing ⚠️
crabs/tracker/track_video.py 40.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
+ Coverage   39.52%   46.16%   +6.64%     
==========================================
  Files          24       24              
  Lines        1417     1460      +43     
==========================================
+ Hits          560      674     +114     
+ Misses        857      786      -71     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sfmig
Copy link
Collaborator

sfmig commented Jun 24, 2024

hey @nikk-nikaznan, I was just having a look at this and I get a different result:

Similarly, if prev_id = [1, 2, 3] and current_id = [1, 2, 3, 4] with current_gt = 4, n_switches = 0. (A new ID is appear in the current frame)

For me this returns n_switches=1
image

I think this is not intended right? Otherwise whenever a crab appears in view (exiting a burrow for example) it will be counted as an ID switch.

@sfmig
Copy link
Collaborator

sfmig commented Jun 24, 2024

I think there is some confusion, because as I understand it from the HOTA paper we only check ID switches for the true positives. So we shouldn't be filtering out missed detections or false negatives inside this function, right?

I got this from sections 3 and 4.1 (included). I recommend it, it is very well explained.

I think we could rewrite the count_identity_switches function to count ID switches as they say in the paper. Following their approach, we could fix the error above and also detect if IDs are swapped between crabs (right now, we don't detect this if all IDs are present in frame f and frame f-1).

@sfmig
Copy link
Collaborator

sfmig commented Jun 24, 2024

I think it would be something like follows:

  1. For the bounding boxes that match the ground truth in frame f (i.e., that overlap sufficiently with the ground truth box), compute the map (dictionary) from ground truth IDs to predicted IDs.
  2. Get the same map for the previous frame f-1 (we would have stored it).
  3. The number of ID switches is the number of times the following thing occurs: for every ground-truth ID (keys of the dictionary), when do the predicted IDs disagree?

Let me know thoughts, happy to chat offline if you prefer.

Copy link
Collaborator

@sfmig sfmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the count_identity_switches is not behaving as expected 🤔

I explained in the comments above ☝️

Maybe a good one to pair program? Let me know thoughts.

crabs/detection_tracking/tracking_utils.py Outdated Show resolved Hide resolved
crabs/detection_tracking/tracking_utils.py Outdated Show resolved Hide resolved
crabs/detection_tracking/inference_model.py Outdated Show resolved Hide resolved
crabs/detection_tracking/inference_model.py Outdated Show resolved Hide resolved
tests/test_unit/test_tracking_utils.py Outdated Show resolved Hide resolved
@nikk-nikaznan nikk-nikaznan marked this pull request as draft June 28, 2024 08:50
@samcunliffe
Copy link
Member

@sfmig I think there is some confusion, because as I understand it from the HOTA paper we only check ID switches for the true positives. So we shouldn't be filtering out missed detections or false negatives inside this function, right?

https://github.com/JonathonLuiten/TrackEval/blob/12c8791b303e0a0b50f753af204249e622d0281a/trackeval/metrics/clear.py#L93-L97

Copy link
Collaborator

@sfmig sfmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Nik! This is great 🌟

I reviewed the rest. Apologies that it's a big one 🙏

The bigger points of this PR are:

  • suggested reimplementation of count_identity_switches function.
  • tracked_list should be a dictionary (following gt_data) rather than a list (otherwise if frames are not valid Python indices it will break).
  • dictionaries that map from ground truth ID to predicted ID to include missed detections.
  • suggestions to rearrange and remove duplicates in the parametrisation of the ID switches test.

Re the first point, I think you are right and with the latest fixes the suggested algorithm doesn't cover any additional cases compared to the current one (contrary to what we thought initially).

However, I think it is a bit easier to read and conceptualise, and it allows us to structure the cases to test. Plus if in the future we want to cover that case of reID after a missed detection gap, I think the suggested algorithm would make it easier.

@nikk-nikaznan nikk-nikaznan requested a review from sfmig July 5, 2024 21:05
Copy link
Collaborator

@sfmig sfmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Nik, it looks great!

Just a few frame_idx to frame_number to avoid confusion when it the frame number is not a valid index to a list / array.

crabs/tracker/utils/io.py Outdated Show resolved Hide resolved
crabs/tracker/track_video.py Show resolved Hide resolved
crabs/tracker/track_video.py Outdated Show resolved Hide resolved
crabs/tracker/track_video.py Outdated Show resolved Hide resolved
crabs/tracker/utils/tracking.py Outdated Show resolved Hide resolved
crabs/tracker/evaluate_tracker.py Outdated Show resolved Hide resolved
crabs/tracker/evaluate_tracker.py Outdated Show resolved Hide resolved
crabs/tracker/evaluate_tracker.py Outdated Show resolved Hide resolved
nikk-nikaznan and others added 7 commits July 9, 2024 12:03
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
Co-authored-by: sfmig <[email protected]>
Signed-off-by: nikk-nikaznan <[email protected]>
@nikk-nikaznan nikk-nikaznan merged commit 99ed754 into main Jul 9, 2024
6 checks passed
@nikk-nikaznan nikk-nikaznan deleted the nikkna/id_switches branch July 9, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants