Closed gitttt-1234 closed 1 month ago
The pull request introduces enhancements to the tracking feature by adding new similarity metrics, "normalized_instance" and "object_keypoint," across various components. These changes are reflected in the command-line interface documentation, configuration files, and implementation of new functions. The updates improve the methods available for measuring similarity, thereby refining the tracking and analysis processes.
File | Change Summary |
---|---|
docs/guides/cli.md, docs/guides/proofreading.md | Added "normalized_instance" and "object_keypoint" to similarity options and described their functionality. |
sleap/config/pipeline_form.yaml | Updated similarity method options to include "normalized_instance." |
sleap/nn/inference.py, sleap/nn/tracking.py | Introduced img_hw parameter to the track method for improved tracking accuracy. |
sleap/nn/tracker/components.py | Introduced normalized_instance_similarity function for normalized keypoint comparison. |
tests/nn/test_inference.py, tests/nn/test_tracker_components.py, tests/nn/test_tracking_integration.py | Expanded test coverage by adding "normalized_instance" and "object_keypoint" to various test functions. |
sequenceDiagram
participant User
participant CLI
participant Config
participant Tracker
participant Test
User->>CLI: Request tracking with normalized_instance
CLI->>Config: Fetch similarity options
Config->>Tracker: Set normalized_instance for tracking
Tracker->>Tracker: Compute similarity using normalized_instance
Tracker->>Test: Validate tracking with new similarity metric
🐰 In the meadow, hopping with glee,
A new metric joins, oh what a spree!
"Normalized_instance," a friend so bright,
Enhancing our tracking, making it right.
With options aplenty, we leap and bound,
In the world of data, joy can be found! 🌼✨
--tracking.similarity
argument, which is directly related to the addition of the keep_viz
option in the training GUI that also affects how visualizations are handled during training.MultiView Stack
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
[!TIP]
Early access features: enabled
We are currently testing the following features in early access: - **OpenAI `o1` for code reviews**: OpenAI's new `o1` model is being tested for code reviews. This model has advanced reasoning capabilities and can provide more nuanced feedback on your code. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues on the [discussion post](https://discordapp.com/channels/1134356397673414807/1279579842131787838).
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 75.37%. Comparing base (
7ed1229
) to head (e1ee966
). Report is 51 commits behind head on develop.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I'm just seeing this PR and it seems similar in spirit to the "object keypoint" similarity (https://github.com/talmolab/sleap/pull/1003) that was recently merged, but not correctly documented I'm afraid (I am the author so I am to blame!).
I'm just seeing this PR and it seems similar in spirit to the "object keypoint" similarity (#1003) that was recently merged, but not correctly documented I'm afraid (I am the author so I am to blame!).
Hi @getzze,
I think part of the problem is that we thought your method was not being hooked up to the GUI at all. Here is where we map the string names of the similarity methods to the actual functions:
The object_keypoint
key is mapping to the same instance_similarity
, though I see now upon closer inspection that it's getting special-cased here:
Docs would definitely help, but either way, I think what we're doing here is a bit different as it's basically just normalizing the keypoints by the image size rather than changing how we account for number of keypoints or confidence.
I suppose the best thing would be to have something more unified that can (optionally?) use all three factors.
For the moment, the easiest might just be to have separate methods as we'll be refactoring a lot of the tracking backend in the coming months anyway as part of our transition to PyTorch.
If you're curious or would like to weigh in on the design of the new backend, check out: https://github.com/talmolab/sleap-nn/issues/53 and the current state of the implementation in this source tree.
Docs would definitely help, but either way, I think what we're doing here is a bit different as it's basically just normalizing the keypoints by the image size rather than changing how we account for number of keypoints or confidence.
There is that, but the key point of object_keypoint_similarity
is actually to normalize the distances before taking the exponential.
You can specify the normalization factor for each node, but what makes more sense is to use the standard error of infering the nodes (say 5 pixels). I didn't find a way to get this error simply though, so the extra parameter (but it's also more flexible like that).
Quoting what I wrote in the original PR #1003 :
- Adding an scale to the distance between the reference and query keypoint. Otherwise, if the ref and query keypoints are 3 pixels apart, they contribute to 0.0001 to the similarity score, versus 0.36 if they are 1 pixel apart. This is very sensitive to single pixel fluctuations. Instead, the distance is divided by a user-defined pixel scale before applying the gaussian function. The scale can be chosen to be the error for each keypoint found during training of the model with the validation set. Ideally this could be retrieved automatically, it is now hidden in the metrics.val.npz file of the model. This is what they use in this paper.
I should have put some explanation in the docs, really sorry about that...
So I think instance_similarity
, object_keypoint_similarity
and normalized_instance_similarity
could be unified, with options to select one or the other.
Thanks for linking to the refactoring of tracking, the roadmap looks very exciting!
Description
Currently, we are facing ID switches in tracking because of very low similarity scores (~/= 0) with instance matching similarity function as it doesn't apply normalization. To address this issue, we add a new
normalized_instance_similarity
function which normalizes the keypoints based on the image size.Types of changes
Does this address any currently open issues?
1815
Outside contributors checklist
Thank you for contributing to SLEAP!
:heart:
Summary by CodeRabbit
New Features
Bug Fixes
Tests