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

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

Conversation

roomrys
Copy link
Collaborator

@roomrys roomrys commented Nov 30, 2023

Description

This PR adds and implements the InstanceGroup datastructure and should be used to update InstanceGroup.

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

Summary by CodeRabbit

  • Refactor

    • Updated imports to streamline camera-related functionalities and types.
  • Tests

    • Adjusted test imports to align with the refactored camera module.
    • Added new test functions for testing InstanceGroup and FrameGroup data structures.

@roomrys roomrys added the MultiView Stack This PR is part of the MultView stacked PRs. label Nov 30, 2023
Copy link

coderabbitai bot commented Nov 30, 2023

Walkthrough

The changes encompass a comprehensive overhaul of the camera-related functionalities in SLEAP. This includes refactoring imports, updating logic for handling instances and points, introducing new data structures, and refining the test suite to align with the enhanced codebase.

Changes

File Path Change Summary
sleap/io/cameras.py Updated imports, added triangulate import, included new types from sleap.types.
sleap/gui/commands.py
sleap/instance.py
Enhanced logic for handling instances and points, respectively.
tests/io/test_cameras.py Added new imports, modified function signatures, introduced InstanceGroup and FrameGroup testing functions.
tests/fixtures/datasets.py Added multiview_min_session_user_labels fixture for minimal session user-labeled data.
tests/gui/test_commands.py Removed various test functions related to multi-view triangulation scenarios.

🐇✨
In the code where cameras lie,
A rabbit hopped, refactoring high.
With types anew, the tests align,
A sleeker codebase, by design. 🌟
🐾📸


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ad5fb9e and 0c057c1.
Files selected for processing (6)
  • sleap/gui/commands.py (2 hunks)
  • sleap/instance.py (2 hunks)
  • sleap/io/cameras.py (7 hunks)
  • tests/fixtures/datasets.py (1 hunks)
  • tests/gui/test_commands.py (1 hunks)
  • tests/io/test_cameras.py (2 hunks)
Files not summarized due to errors (1)
  • sleap/io/cameras.py: Error: Message exceeds token limit
Additional comments not posted (15)
tests/fixtures/datasets.py (1)

283-288: The new fixture multiview_min_session_user_labels correctly loads user-labeled data for a minimal session. This aligns with the PR's objective to enhance data handling capabilities.

tests/io/test_cameras.py (3)

8-14: The updated imports correctly include InstanceGroup and FrameGroup, which are necessary for the new functionalities being tested.


292-339: The function create_instance_group has been updated to optionally include a dummy instance in the returned data. This is useful for testing scenarios where not all data points are valid or present. The implementation handles the conditional logic and data structure manipulation correctly.


342-416: The test test_instance_group effectively checks the functionality of the InstanceGroup data structure, including edge cases with the dummy instance. The assertions cover various properties and methods, ensuring the structure behaves as expected.

sleap/instance.py (8)

Line range hint 34-63: LGTM! The Point class implementation is clear and well-defined.


Line range hint 75-110: LGTM! The PredictedPoint class correctly extends the Point class with additional functionality for handling prediction scores.


Line range hint 118-183: LGTM! The PointArray class provides necessary functionality for handling arrays of Point objects efficiently.


Line range hint 185-209: LGTM! The PredictedPointArray class correctly extends PointArray to handle PredictedPoint objects, maintaining consistency in the API.


Line range hint 211-235: LGTM! The Track class implementation is straightforward and provides essential functionality for tracking objects across frames.


500-505: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [237-729]

The methods in the Instance class are well-implemented and cover a wide range of functionalities required for managing instances in SLEAP.


Line range hint 1654-1791: LGTM! The PredictedInstance class correctly extends the Instance class to handle additional attributes and functionalities specific to predicted instances.


Line range hint 1793-2428: LGTM! The LabeledFrame class provides comprehensive functionality for managing labeled data within a single frame, including methods for merging frames and handling instances.

sleap/gui/commands.py (3)

3421-3425: Consider handling the case where instance_group is None more explicitly.

It might be beneficial to add a specific error message or handling logic when instance_group is None, as this could indicate a deeper issue with the data or assumptions being made.


3444-3449: Ensure that the triangulate function handles exceptions or errors gracefully.


3458-3465: Validate the dimensions and data integrity of points_reprojected before updating.

Consider adding checks to ensure that the dimensions and data integrity of points_reprojected are as expected before calling upsert_points. This can prevent potential runtime errors or data corruption.


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-method-for-multi-instance-products November 30, 2023 19:56
@roomrys
Copy link
Collaborator Author

roomrys commented Nov 30, 2023

@coderabbitai review

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7ee80b0 and ad5fb9e.
Files selected for processing (2)
  • sleap/io/cameras.py (2 hunks)
  • tests/io/test_cameras.py (2 hunks)
Additional comments: 8
sleap/io/cameras.py (5)
  • 5-5: The import of cast from the typing module is consistent with the summary.

  • 5-5: The removal of triangulate from the sleap_anipose import is consistent with the summary.

  • 5-5: The addition of new imports from sleap.types is consistent with the summary.

  • 5-5: The import of Labels from sleap.io.dataset is consistent with the summary.

  • 759-899: The addition of the InstanceGroup class is consistent with the summary of the pull request, which indicates that this is a new feature.

tests/io/test_cameras.py (3)
  • 6-8: The import changes reflect the addition of the InstanceGroup class and the removal of unused imports, which aligns with the summary.

  • 283-320: The new test case for InstanceGroup is well-structured and covers the creation of an InstanceGroup from a dictionary, as well as the retrieval of instances by camera and vice versa. This aligns with the introduction of the new InstanceGroup class as described in the summary.

  • 278-320: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-320]

No further issues or improvements are identified in the provided hunks. The changes are consistent with the summary and the pull request description.

Comment on lines 891 to 893
frame_idx = cast(
int, frame_idx
) # Could be None if no real instances in dictionary
Copy link

Choose a reason for hiding this comment

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

The use of cast to convert frame_idx to an integer may not be safe if frame_idx can be None. Consider adding a check to ensure frame_idx is not None before casting.

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: Patch coverage is 76.88172% with 43 lines in your changes are missing coverage. Please review.

Project coverage is 73.85%. Comparing base (443d410) to head (95071c1).

❗ Current head 95071c1 differs from pull request most recent head 0c057c1. Consider uploading reports for the commit 0c057c1 to get more accurate results

Files Patch % Lines
sleap/io/cameras.py 71.42% 42 Missing ⚠️
sleap/gui/commands.py 96.77% 1 Missing ⚠️
Additional details and impacted files
@@                                 Coverage Diff                                  @@
##           liezl/add-method-to-match-instances-across-views    #1618      +/-   ##
====================================================================================
+ Coverage                                             73.81%   73.85%   +0.03%     
====================================================================================
  Files                                                   135      135              
  Lines                                                 24636    24807     +171     
====================================================================================
+ Hits                                                  18186    18322     +136     
- Misses                                                 6450     6485      +35     

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

@roomrys
Copy link
Collaborator Author

roomrys commented Dec 2, 2023

   Ordered by: cumulative time
   List reduced from 5387 to 100 due to restriction <100>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000   11.447   11.447 runner.py:111(pytest_runtest_protocol)
    17/11    0.000    0.000   11.447    1.041 _hooks.py:427(__call__)
    17/11    0.000    0.000   11.447    1.041 _manager.py:103(_hookexec)
    17/11    0.000    0.000   11.447    1.041 _callers.py:30(_multicall)
        1    0.000    0.000   11.446   11.446 runner.py:119(runtestprotocol)
        3    0.000    0.000   11.446    3.815 runner.py:219(call_and_report)
        3    0.000    0.000   11.446    3.815 runner.py:247(call_runtest_hook)
        3    0.000    0.000   11.446    3.815 runner.py:318(from_call)
        3    0.000    0.000   11.446    3.815 runner.py:262(<lambda>)
        1    0.000    0.000   11.427   11.427 runner.py:160(pytest_runtest_call)
        1    0.000    0.000   11.427   11.427 python.py:1790(runtest)
        1    0.000    0.000   11.427   11.427 python.py:187(pytest_pyfunc_call)
        1    0.000    0.000   11.427   11.427 test_commands.py:1304(test_triangulate_session)
        2    0.000    0.000   11.427    5.714 commands.py:617(triangulateSession)
        2    0.000    0.000   11.427    5.714 commands.py:242(execute)
        2    0.000    0.000   11.427    5.714 commands.py:109(execute)
        2    0.000    0.000   11.416    5.708 commands.py:158(do_with_signal)
        2    0.000    0.000   11.416    5.708 commands.py:3393(do_action)
        2    0.000    0.000   11.416    5.708 commands.py:3766(get_instance_grouping_and_reprojected_coords)
        2    0.000    0.000   11.416    5.708 commands.py:3998(calculate_error_per_frame)
        2    0.023    0.012   11.416    5.708 commands.py:3858(_calculate_reprojection_error)
        2    0.000    0.000   10.871    5.435 commands.py:4391(calculate_reprojected_points)
        2    0.000    0.000   10.833    5.417 commands.py:4271(_calculate_reprojected_points)
        2    0.000    0.000   10.509    5.255 triangulation.py:72(triangulate)
        2    0.000    0.000   10.509    5.254 triangulation.py:177(<listcomp>)
        4    0.012    0.003   10.509    2.627 cameras.py:1161(triangulate_optim)
        6    0.000    0.000    8.176    1.363 dispatcher.py:388(_compile_for_args)
     33/9    0.000    0.000    7.983    0.887 compiler.py:469(_compile_core)

Comment on lines 4069 to 4073
# Possible race condition
if selected_cam not in instances:
raise RuntimeError(
f"Selected camera {selected_cam} not in instances at frame {frame_idx}."
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While this will help prevent a KeyError if the instance has not yet been added from the selected_cam - this does not handle the case when an instance is already available for the selected_cam, but we double click another PredictedInstance in the same view.

@roomrys roomrys self-assigned this Jan 5, 2024
@roomrys roomrys changed the base branch from liezl/add-method-for-multi-instance-products to liezl/add-method-to-match-instances-across-views January 20, 2024 15:55
@roomrys roomrys changed the title (3e -> 3d) Add InstanceGroup class (3e -> 3a) Add InstanceGroup class Mar 20, 2024
roomrys and others added 7 commits March 20, 2024 17:29
* 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)
@roomrys roomrys marked this pull request as ready for review April 12, 2024 15:32
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: 49

Actionable comments outside the diff hunks (15)
tests/fixtures/datasets.py (1)

Line range hint 1-1: Remove unused import to clean up the code.

- import os
tests/gui/test_commands.py (13)

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.

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     assert okay is True
+     assert okay

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

-     fly32_json = get_package_file(f"skeletons/fly32.json")
+     fly32_json = get_package_file("skeletons/fly32.json")
sleap/io/cameras.py (1)

Line range hint 80-82: Consider removing the f-string formatting as there are no placeholders used in these strings.

-            raise AttributeError(
-                f"No camera has been specified. "
-                f"This is likely because the `Camcorder.from_dict` method was not used to initialize this object. "
-                f"Please use `Camcorder.from_dict` to recreate the object."
-            )
+            raise AttributeError(
+                "No camera has been specified. "
+                "This is likely because the `Camcorder.from_dict` method was not used to initialize this object. "
+                "Please use `Camcorder.from_dict` to recreate the object."
+            )

return

# Get params
# Get `FrameGroup` for the current frame index
Copy link

Choose a reason for hiding this comment

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

Ensure video and session parameters are properly handled when not provided.

- video = params.get("video", None) or context.state["video"]
- session = params.get("session", None) or context.labels.get_session(video)
+ video = params.get("video") if "video" in params else context.state["video"]
+ session = params.get("session") if "session" in params else context.labels.get_session(video)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# Get `FrameGroup` for the current frame index
# Get `FrameGroup` for the current frame index
video = params.get("video") if "video" in params else context.state["video"]
session = params.get("session") if "session" in params else context.labels.get_session(video)

Comment on lines +731 to +755

# Skip if new point is nan or old point is complete
if np.isnan(point_new).any() or (exclude_complete and points_old.complete):
continue
points_dict[node_name] = Point(x=point_new[0], y=point_new[1])

# Grab the x, y from the new point and visible, complete from the old point
x, y = point_new
visible = points_old.visible
complete = points_old.complete

# Create a new point and add to the dict
if type(self._points) == PredictedPointArray:
# TODO(LM): The point score is meant to rate the confidence of the
# prediction, but this method updates from triangulation.
score = points_old.score
point_obj = PredictedPoint(
x=x, y=y, visible=visible, complete=complete, score=score
)
else:
point_obj = Point(x=x, y=y, visible=visible, complete=complete)

# Update the points dict
points_dict[node_name] = point_obj

# Update the points
Copy link

Choose a reason for hiding this comment

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

Consider refining the handling of PredictedPoint objects in the update_points method. The current implementation may not correctly handle cases where the score attribute needs to be updated based on new data.

-                score = points_old.score
+                score = calculate_new_score(points_old, point_new)  # This is a placeholder for the actual score calculation logic.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# Skip if new point is nan or old point is complete
if np.isnan(point_new).any() or (exclude_complete and points_old.complete):
continue
points_dict[node_name] = Point(x=point_new[0], y=point_new[1])
# Grab the x, y from the new point and visible, complete from the old point
x, y = point_new
visible = points_old.visible
complete = points_old.complete
# Create a new point and add to the dict
if type(self._points) == PredictedPointArray:
# TODO(LM): The point score is meant to rate the confidence of the
# prediction, but this method updates from triangulation.
score = points_old.score
point_obj = PredictedPoint(
x=x, y=y, visible=visible, complete=complete, score=score
)
else:
point_obj = Point(x=x, y=y, visible=visible, complete=complete)
# Update the points dict
points_dict[node_name] = point_obj
# Update the points
# Skip if new point is nan or old point is complete
if np.isnan(point_new).any() or (exclude_complete and points_old.complete):
continue
# Grab the x, y from the new point and visible, complete from the old point
x, y = point_new
visible = points_old.visible
complete = points_old.complete
# Create a new point and add to the dict
if type(self._points) == PredictedPointArray:
# TODO(LM): The point score is meant to rate the confidence of the
# prediction, but this method updates from triangulation.
score = calculate_new_score(points_old, point_new) # This is a placeholder for the actual score calculation logic.
point_obj = PredictedPoint(
x=x, y=y, visible=visible, complete=complete, score=score
)
else:
point_obj = Point(x=x, y=y, visible=visible, complete=complete)
# Update the points dict
points_dict[node_name] = point_obj
# Update the points

# Update instances
TriangulateSession.update_instances(
instances_and_coords=instances_and_reprojected_coords
frame_idx: int = params["frame_idx"]
Copy link

Choose a reason for hiding this comment

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

Validate frame_idx parameter to ensure it is provided.

- frame_idx: int = params["frame_idx"]
+ frame_idx: int = params.get("frame_idx")
+ if frame_idx is None:
+     raise ValueError("frame_idx parameter is required for triangulation.")

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
frame_idx: int = params["frame_idx"]
frame_idx: int = params.get("frame_idx")
if frame_idx is None:
raise ValueError("frame_idx parameter is required for triangulation.")

Comment on lines +3435 to +3436
if instance_groups is None or len(instance_groups) == 0:
return # Not enough instances for triangulation
Copy link

Choose a reason for hiding this comment

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

Add error handling for the case where no instance groups are available for triangulation.

- return  # Not enough instances for triangulation
+ raise ValueError("No instance groups available for triangulation.")

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if instance_groups is None or len(instance_groups) == 0:
return # Not enough instances for triangulation
if instance_groups is None or len(instance_groups) == 0:
raise ValueError("No instance groups available for triangulation.")

Comment on lines +412 to +414
_instance_by_camcorder: Dict[Camcorder, "Instance"] = field(factory=dict)
_camcorder_by_instance: Dict["Instance", Camcorder] = field(factory=dict)
_dummy_instance: Optional["Instance"] = field(default=None)
Copy link

Choose a reason for hiding this comment

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

The name Instance is used but not defined in this scope.

Please ensure that the Instance class is correctly imported or defined within this file or module to avoid runtime errors.

# Create a dummy instance of all nan values
example_instance: "Instance" = next(iter(all_instances_by_camera[0]))
skeleton: "Skeleton" = example_instance.skeleton
dummy_instance: "Instance" = example_instance.from_numpy(
Copy link

Choose a reason for hiding this comment

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

The name Instance is used but not defined in this scope.

Please ensure that the Instance class is correctly imported or defined within this file or module to avoid runtime errors.

)

def _fill_in_missing_instances(
unlocked_instances_in_view: List["Instance"],
Copy link

Choose a reason for hiding this comment

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

The name Instance is used but not defined in this scope.

Please ensure that the Instance class is correctly imported or defined within this file or module to avoid runtime errors.


# For each view, get permutations of unlocked instances
unlocked_instance_permutations: Dict[
Camcorder, Iterator[Tuple["Instance"]]
Copy link

Choose a reason for hiding this comment

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

The name Instance is used but not defined in this scope.

Please ensure that the Instance class is correctly imported or defined within this file or module to avoid runtime errors.

for cam, instances_in_view in instances_by_camera.items():
# Gather all instances for this cam from locked `InstanceGroup`s
locked_instances_in_view: Set[
"Instance"
Copy link

Choose a reason for hiding this comment

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

The name Instance is used but not defined in this scope.

Please ensure that the Instance class is correctly imported or defined within this file or module to avoid runtime errors.

] = self._locked_instances_by_cam.get(cam, set())

# Remove locked instances from instances in view
unlocked_instances_in_view: List["Instance"] = list(
Copy link

Choose a reason for hiding this comment

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

The name Instance is used but not defined in this scope.

Please ensure that the Instance class is correctly imported or defined within this file or module to avoid runtime errors.

@roomrys roomrys merged commit c3a8173 into liezl/add-method-to-match-instances-across-views Apr 12, 2024
5 checks passed
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
@roomrys roomrys deleted the liezl/add-instance-group-class branch April 18, 2024 20:05
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.

1 participant