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

(3g -> 3f) Use frame group for triangulation #1693

Merged
merged 13 commits into from
Apr 12, 2024

Conversation

roomrys
Copy link
Collaborator

@roomrys roomrys commented Feb 16, 2024

Description

This PR makes use of the FrameGroup and InstanceGroup classes and uses them for triangulation.

Types of changes

  • Bugfix
  • New feature
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (explain)

Does this address any currently open issues?

[list open issues here]

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

Summary by CodeRabbit

  • New Features

    • Enhanced the triangulation process in the GUI by improving instance group handling, ensuring sufficient data is present for successful triangulation.
  • Tests

    • Removed outdated tests related to triangulation to align with the updated functionality.

Copy link

coderabbitai bot commented Feb 16, 2024

Walkthrough

The modifications in the sleap project focus on enhancing the FrameGroup class to better support instance triangulation, alongside a significant reduction in the associated unit tests. This suggests a streamlined approach in handling triangulation, possibly indicating a shift in how instances are verified and triangulated within the application.

Changes

File Path Summary
sleap/gui/commands.py Updated FrameGroup class to better filter and handle instance groups for triangulation.
tests/gui/test_commands.py Removed multiple test functions related to triangulation, reducing testing coverage.

🐰🌟
To the code that leaps and bounds,
Through digital fields, where logic sounds.
Triangulate with care and might,
In SLEAP's realm, enhance the sight.
Oh, how the frames now smartly group,
With fewer tests, the project's troop!
🎉🐾


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 628d7db and efbafda.
Files selected for processing (2)
  • sleap/gui/commands.py (2 hunks)
  • tests/gui/test_commands.py (1 hunks)
Additional comments not posted (1)
sleap/gui/commands.py (1)

3409-3465: Ensure that the triangulation process correctly filters and handles instance groups based on the new criteria.

The changes in the triangulateSession method involve updating the handling of FrameGroup and InstanceGroup to ensure that only instance groups with a sufficient number of instances are considered for triangulation. This aligns with the PR's objective to enhance the triangulation process by utilizing these classes more effectively.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@roomrys roomrys changed the base branch from develop to liezl/add-frame-group February 16, 2024 17:02
@roomrys roomrys added the MultiView Stack This PR is part of the MultView stacked PRs. label Mar 19, 2024
@roomrys roomrys changed the title (3e -> 3f) Use frame group for triangulation (3g -> 3f) Use frame group for triangulation Mar 19, 2024
@roomrys roomrys marked this pull request as ready for review April 12, 2024 15:26
@roomrys roomrys merged commit ff0924e into liezl/add-frame-group Apr 12, 2024
4 of 5 checks passed
@roomrys roomrys deleted the liezl/use-frame-group-for-triangulation branch April 12, 2024 15:27
roomrys added a commit that referenced this pull request Apr 12, 2024
* Add FrameGroup class

* Replace _get_instances_by_camera with maintained _instances_by_cam

* Convert enforce_frame_idx_unique to regular method

* Write (failing) FrameGroup test

* Get FrameGroup.session validator working

* Get rid of test_instance_group bug

* Fix create_instance_group bug

* Fix failing tests

* Add update_points, get_instance_group, and numpy methods

* Add `get_instances` method

* Rename `update_points` to `upsert_points` and numpy multiple `InstanceGroup`s

* Create and add missing instance when updating reprojections

* Add method to add `Instance`s and `InstanceGroup`s

* Create new InstanceGroup if instance_group is None in add_instance_group

* (3g -> 3f) Use frame group for triangulation (#1693)
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Actionable comments outside the diff hunks (15)
tests/gui/test_commands.py (7)

Line range hint 5-5: Remove unused import Dict.

- from typing import Dict, List
+ from typing import List

Line range hint 7-7: Remove unused import numpy.

- import numpy as np

Line range hint 21-21: Remove unused import TriangulateSession.

- from sleap.gui.commands import (
-     AddSession,
-     CommandContext,
-     ExportAnalysisFile,
-     ExportDatasetWithImages,
-     ImportDeepLabCutFolder,
-     OpenSkeleton,
-     RemoveVideo,
-     ReplaceVideo,
-     SaveProjectAs,
-     TriangulateSession,
-     get_new_version_filename,
- )
+ from sleap.gui.commands import (
+     AddSession,
+     CommandContext,
+     ExportAnalysisFile,
+     ExportDatasetWithImages,
+     ImportDeepLabCutFolder,
+     OpenSkeleton,
+     RemoveVideo,
+     ReplaceVideo,
+     SaveProjectAs,
+     get_new_version_filename,
+ )

Line range hint 25-25: Remove unused import Camcorder.

- from sleap.io.cameras import Camcorder

Line range hint 227-227: Use if okay: instead of if okay is True: for truth checks.

- if okay is True:
+ if okay:

Line range hint 368-368: Use if video.backend.grayscale: instead of if video.backend.grayscale is True: for truth checks.

- if video.backend.grayscale is True:
+ if video.backend.grayscale:

Line range hint 528-528: Remove unnecessary f-string as it contains no placeholders.

- filename = get_package_file(f"skeletons/fly32.json")
+ filename = get_package_file("skeletons/fly32.json")
sleap/gui/commands.py (8)

Line range hint 38-40: Remove unused imports to clean up the code.

- from itertools import permutations, product
- from typing import Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, cast
+ from typing import Callable, Dict, Iterator, List, Optional, Tuple, Type, Union

Line range hint 196-196: Undefined name MainWindow used. Ensure that MainWindow is defined or imported correctly in this context.


Line range hint 838-838: Local variable file_dir is assigned but never used. Consider removing it if it's unnecessary.

- file_dir = os.path.dirname(filename)

Line range hint 1712-1712: Avoid using bare except statements. Specify exception types to handle specific exceptions appropriately.

- except:
+ except Exception as e:

Line range hint 1733-1733: Avoid using bare except statements. Specify exception types to handle specific exceptions appropriately.

- except:
+ except Exception as e:

Line range hint 2470-2470: The f-string does not contain any placeholders. Use a regular string instead.

- f"Please select the area from which to remove instances. This will be applied to all frames."
+ "Please select the area from which to remove instances. This will be applied to all frames."

Line range hint 2802-2802: The f-string does not contain any placeholders. Use a regular string instead.

- f"An error occurred while generating suggestions. "
+ "An error occurred while generating suggestions. "

Line range hint 3145-3145: Avoid using bare except statements. Specify exception types to handle specific exceptions appropriately.

- except:
+ except Exception as e:

roomrys added a commit that referenced this pull request Apr 12, 2024
* Add method to get single instance permutations

* Add method and (failing) test to get instance grouping

* Append a dummy instance for missing instances

* Update tests to accept a dummy instance

* Add initial InstanceGroup class

* Few extra tests for `InstanceGroup`

* Remember instance grouping after testing hypotheses

* Use reconsumable iterator for reprojected coords

* Only triangulate user instances, add fixture, update tests

* Normalize instance reprojection errors

* Add `locked`, `_dummy_instance`, `numpy`, and `update_points`

* Allow `PredictedPoint`s to be updated as well

* Add tests for new attributes and methods

* Add methods to create, add, replace, and remove instances

* Use PredictedInstance for new/dummy instances

* (3f -> 3e) Add `FrameGroup` class  (#1665)

* (3g -> 3f) Use frame group for triangulation (#1693)
roomrys added a commit that referenced this pull request Apr 18, 2024
* Update  methods to allow triangulating multiple instances at once

* Return instances and coords as a dictionary with cams

* Update get_instance_across_views to handle multiple frames

* [wip] Update calculate reprojected points to support multiple frames

* Finish support for multi-frame reprojection

* Remove code to put in next PR

* (3b -> 3a) Add method to get single instance permutations (#1586)

* Add method to get single instance permutations

* Append a dummy instance for missing instances

* Correct 'permutations' to 'products'

* (3c -> 3b) Add method to test instance grouping (#1599)

* (3d -> 3c) Add method for multi instance products (#1605)

* (3e -> 3a) Add `InstanceGroup` class (#1618)

* Add method to get single instance permutations

* Add method and (failing) test to get instance grouping

* Append a dummy instance for missing instances

* Update tests to accept a dummy instance

* Add initial InstanceGroup class

* Few extra tests for `InstanceGroup`

* Remember instance grouping after testing hypotheses

* Use reconsumable iterator for reprojected coords

* Only triangulate user instances, add fixture, update tests

* Normalize instance reprojection errors

* Add `locked`, `_dummy_instance`, `numpy`, and `update_points`

* Allow `PredictedPoint`s to be updated as well

* Add tests for new attributes and methods

* Add methods to create, add, replace, and remove instances

* Use PredictedInstance for new/dummy instances

* (3f -> 3e) Add `FrameGroup` class  (#1665)

* (3g -> 3f) Use frame group for triangulation (#1693)

* Only use user-`Instance`s for triangulation

* Remove unused code

* Use `LabeledFrame` class instead of dummy labeled frame

* Limit which methods can update `Labels.labeled_frames`

* Update cache when Labels. remove_session_video

* Remove RecordingSession.instance_groups

* [wip] Maintain cached FrameGroup dictionaries

* Add unique name (per FrameGroup) requirement for InstanceGroup

* Lint

* Fix remove_video bug

* Add RecordingSession.new_frame_group method

* Add TODO comments for later

* Fix RecordingSesssion.remove_video bug

* Remove FrameGroup._frame_idx_registry class attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiView Stack This PR is part of the MultView stacked PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants