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

Add minimal pretrained checkpoints for tests and fix PAF grouping interpolation #73

Merged
merged 14 commits into from
Sep 12, 2024

Conversation

gqcpm
Copy link
Contributor

@gqcpm gqcpm commented Aug 7, 2024

This PR addresses Issue: #56. Additionally, this also modifies make_line_subs function in inference/paf_grouping.py by using interpolate function to generate candidates.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced configuration structure for training, preprocessing, and augmentation, improving clarity and usability.
    • Introduced flags for specifying training and validation label paths, augmentations, and model types.
    • Added parameters for resuming training from checkpoints and tracking previous runs.
    • Introduced new augmentation functions for intensity and geometric transformations.
  • Bug Fixes

    • Improved error handling for unsupported configurations and model types.
  • Documentation

    • Updated documentation to reflect changes in configuration structure and usage.
  • Tests

    • Expanded test coverage for augmentation functionalities and model training processes.
    • Restructured test cases to align with new configuration standards and improve clarity.
  • Chores

    • Code refactoring for better maintainability and readability across the configuration and model training processes.

gitttt-1234 and others added 6 commits July 23, 2024 16:30
* Refactor preprocessing config

* Merge train and val data configs

* Remove pipeline name

* Modify backbone_config

* Modify ckpts

* Fix inference tests

* Fix device for inference

* Fix scale in inference

* Fix Predictor

* Modify `bottom_up` to `bottomup`

* Fix bottomup inference

* Fix scale in augmentation
* Refactor preprocessing config

* Merge train and val data configs

* Remove pipeline name

* Modify backbone_config

* Modify ckpts

* Fix inference tests

* Fix device for inference

* Fix scale in inference

* Fix Predictor

* Modify `bottom_up` to `bottomup`

* Fix bottomup inference

* Fix scale in augmentation

* Test remove image

* Fix instance cropping

* Fix tests

* Remove scale in pipelines
Copy link
Contributor

coderabbitai bot commented Aug 7, 2024

Walkthrough

The configuration structure has been extensively reorganized to enhance clarity and usability across various files. Key updates include the renaming of label paths, the introduction of streamlined augmentation settings, and an improved organization of model configurations. Additionally, new parameters for resuming training from checkpoints have been added, alongside enhancements to the augmentation and data processing logic. These changes facilitate easier management of training parameters, provide a better understanding of model architecture, and support effective application of data augmentations.

Changes

Files Change Summary
docs/config.md, docs/config_bottomup.yaml, docs/config_centroid.yaml, docs/config_topdown_centered_instance.yaml Significant restructuring of configuration files, including renaming label paths, simplifying augmentation settings, and enhancing model configurations for clarity and usability.
sleap_nn/data/augmentation.py, sleap_nn/data/pipelines.py, sleap_nn/tracking/candidates/fixed_window.py Modifications to function parameters, introduction of more flexible handling for model types, and adjustments to augmentation methods for improved clarity and functionality.
tests/**/*.py (various test files) Updates to test configurations, standardization of parameter handling, and improvements in error handling, enhancing robustness and consistency across tests.
tests/assets/minimal_instance/*.yaml, tests/assets/minimal_instance_bottomup/*.yaml, tests/assets/minimal_instance_centroid/*.yaml Consolidation of configuration parameters, introduction of clear distinctions between training and validation configurations, and simplification of augmentation settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Config
    participant Model
    participant Augmentor

    User->>Config: Load configuration
    Config->>Model: Set up model parameters
    Config->>Augmentor: Configure data augmentations
    Augmentor-->>Config: Return augmentation settings
    Model-->>User: Ready for training
Loading

🐰 "In fields of green where bunnies hop,
Configuration changes make us stop.
With clearer paths and augments bright,
Training's now a sheer delight!
Let's bound ahead, our work is done,
With joyful leaps, we’ve just begun!"
🌼


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

Copy link
Contributor

@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: 12

Outside diff range, codebase verification and nitpick comments (10)
docs/config_topdown_centered_instance.yaml (2)

87-87: Review and update device and accelerator settings.

The trainer_accelerator is set to gpu in docs/config_topdown_centered_instance.yaml, but there's a comment indicating that the device and trainer accelerator settings need to be redone. Please review and update these settings to ensure they align with your hardware and training objectives.

  • File: docs/config_topdown_centered_instance.yaml
  • Line: Contains a TODO comment regarding device and accelerator settings.
Analysis chain

Verify device and accelerator settings.

The trainer_accelerator is set to gpu. Ensure that this aligns with your available hardware and training objectives.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the device and accelerator settings.

# Test: Check if the trainer accelerator is correctly specified. Expect: The trainer accelerator should be `gpu`.
rg --type yaml "trainer_accelerator: gpu"

Length of output: 209


3-4: Label paths are missing

The specified paths for train_labels_path and val_labels_path (docs/minimal_instance.pkg.slp) do not exist in the repository. Please verify the correct paths or ensure that the necessary files are included in the repository.

  • Paths checked: docs/minimal_instance.pkg.slp for both train and validation labels.
Analysis chain

Verify the correctness of label paths.

Ensure that the paths train_labels_path: minimal_instance.pkg.slp and val_labels_path: minimal_instance.pkg.slp are correct and accessible.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the specified label paths.

# Test: Check if the specified label paths exist. Expect: Files should exist.
test -f "docs/minimal_instance.pkg.slp" && echo "Train labels path exists." || echo "Train labels path missing."
test -f "docs/minimal_instance.pkg.slp" && echo "Validation labels path exists." || echo "Validation labels path missing."

Length of output: 215

docs/config_bottomup.yaml (1)

3-4: Label paths are missing or incorrect.

The specified paths train_labels_path: minimal_instance.pkg.slp and val_labels_path: minimal_instance.pkg.slp do not exist in the repository. Please verify the paths or ensure the files are added to the repository.

  • Check if docs/minimal_instance.pkg.slp is the correct path.
  • Ensure the necessary files are included in the repository.
Analysis chain

Verify the correctness of label paths.

Ensure that the paths train_labels_path: minimal_instance.pkg.slp and val_labels_path: minimal_instance.pkg.slp are correct and accessible.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the specified label paths.

# Test: Check if the specified label paths exist. Expect: Files should exist.
test -f "docs/minimal_instance.pkg.slp" && echo "Train labels path exists." || echo "Train labels path missing."
test -f "docs/minimal_instance.pkg.slp" && echo "Validation labels path exists." || echo "Validation labels path missing."

Length of output: 215

tests/inference/test_predictors.py (1)

Line range hint 49-49: Avoid using broad exception handling.

Using pytest.raises(Exception) is discouraged as it can catch unintended exceptions, making debugging difficult. Consider specifying a more precise exception type.

- with pytest.raises(Exception):
+ with pytest.raises(ValueError):
docs/config.md (3)

16-18: Fix unordered list indentation.

The indentation of list items is inconsistent with markdownlint guidelines.

-    - `train_labels_path`: (str) Path to training data (`.slp` file)
-    - `val_labels_path`: (str) Path to validation data (`.slp` file)
-        - `scale`: (float or List[float]) Factor to resize the image dimensions by, specified as either a float scalar or as a 2-tuple of [scale_x, scale_y]. If a scalar is provided, both dimensions are resized by the same factor. 
+  - `train_labels_path`: (str) Path to training data (`.slp` file)
+  - `val_labels_path`: (str) Path to validation data (`.slp` file)
+      - `scale`: (float or List[float]) Factor to resize the image dimensions by, specified as either a float scalar or as a 2-tuple of [scale_x, scale_y]. If a scalar is provided, both dimensions are resized by the same factor. 

Also applies to: 28-29, 30-31

Tools
Markdownlint

16-16: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


17-17: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


18-18: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


63-64: Fix unordered list indentation.

The indentation of list items is inconsistent with markdownlint guidelines.

-    - `backbone_type`: (str) Backbone architecture for the model to be trained. One of "unet", "convnext" or "swint".
-    - `backbone_config`: (for UNet)
-    - `backbone_config`: (for ConvNext)
-    - `head_configs`: (Dict) Dictionary with the following keys having head configs for the model to be trained. **Note**: Configs should be provided only for the model to train and others should be `None`.
+  - `backbone_type`: (str) Backbone architecture for the model to be trained. One of "unet", "convnext" or "swint".
+  - `backbone_config`: (for UNet)
+  - `backbone_config`: (for ConvNext)
+  - `head_configs`: (Dict) Dictionary with the following keys having head configs for the model to be trained. **Note**: Configs should be provided only for the model to train and others should be `None`.

Also applies to: 80-81, 95-96, 111-112

Tools
Markdownlint

63-63: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


64-64: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


159-159: Fix unordered list indentation.

The indentation of list items is inconsistent with markdownlint guidelines.

-    - `wandb`: (Only if `use_wandb` is `True`, else skip this)
+  - `wandb`: (Only if `use_wandb` is `True`, else skip this)
Tools
Markdownlint

159-159: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)

sleap_nn/training/model_trainer.py (2)

70-70: Initialize model_type with a default value.

Consider setting a default value for model_type during initialization to prevent potential issues if it remains unset.

- self.model_type = None
+ self.model_type = "unknown"

Line range hint 308-321: Document the model_type parameter in the constructor.

Ensure that the model_type parameter is clearly documented in the constructor's docstring for better understanding.

        """
        Initialise the configs and the model.
        
        Args:
            config: OmegaConf dictionary with model configurations.
            skeletons: List of sio.Skeleton objects.
+           model_type: Type of the model. One of `single_instance`, `centered_instance`, `centroid`, `bottomup`.
        """
sleap_nn/inference/predictors.py (1)

Line range hint 86-106: Update docstring for peak_threshold parameter.

Ensure the docstring reflects the new functionality of peak_threshold accepting a list for different model types.

            peak_threshold: (float or List[float]) Minimum confidence threshold. Peaks with values below
                this will be ignored. Default: 0.2. This can also be `List[float]` for topdown
                centroid and centered-instance model, where the first element corresponds
                to centroid model peak finding threshold and the second element is for
                centered-instance model peak finding.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 08ac252 and 445bd4d.

Files selected for processing (24)
  • docs/config.md (4 hunks)
  • docs/config_bottomup.yaml (4 hunks)
  • docs/config_centroid.yaml (5 hunks)
  • docs/config_topdown_centered_instance.yaml (4 hunks)
  • sleap_nn/architectures/model.py (2 hunks)
  • sleap_nn/data/augmentation.py (7 hunks)
  • sleap_nn/data/pipelines.py (7 hunks)
  • sleap_nn/inference/predictors.py (30 hunks)
  • sleap_nn/training/model_trainer.py (17 hunks)
  • tests/architectures/test_model.py (15 hunks)
  • tests/assets/minimal_instance/initial_config.yaml (3 hunks)
  • tests/assets/minimal_instance/training_config.yaml (4 hunks)
  • tests/assets/minimal_instance_bottomup/initial_config.yaml (3 hunks)
  • tests/assets/minimal_instance_bottomup/training_config.yaml (4 hunks)
  • tests/assets/minimal_instance_centroid/initial_config.yaml (3 hunks)
  • tests/assets/minimal_instance_centroid/training_config.yaml (4 hunks)
  • tests/data/test_augmentation.py (2 hunks)
  • tests/data/test_pipelines.py (22 hunks)
  • tests/fixtures/datasets.py (3 hunks)
  • tests/inference/test_bottomup.py (3 hunks)
  • tests/inference/test_predictors.py (12 hunks)
  • tests/inference/test_single_instance.py (3 hunks)
  • tests/inference/test_topdown.py (4 hunks)
  • tests/training/test_model_trainer.py (15 hunks)
Files skipped from review due to trivial changes (1)
  • tests/data/test_augmentation.py
Additional context used
yamllint
docs/config_topdown_centered_instance.yaml

[error] 6-6: trailing spaces

(trailing-spaces)


[error] 7-7: trailing spaces

(trailing-spaces)


[warning] 27-27: wrong indentation: expected 4 but found 6

(indentation)


[error] 34-34: trailing spaces

(trailing-spaces)


[error] 71-71: trailing spaces

(trailing-spaces)

docs/config_bottomup.yaml

[error] 65-65: trailing spaces

(trailing-spaces)


[warning] 70-70: wrong indentation: expected 8 but found 10

(indentation)


[warning] 75-75: wrong indentation: expected 8 but found 10

(indentation)

docs/config_centroid.yaml

[error] 6-6: trailing spaces

(trailing-spaces)


[error] 7-7: trailing spaces

(trailing-spaces)


[warning] 47-47: wrong indentation: expected 4 but found 6

(indentation)


[error] 54-54: trailing spaces

(trailing-spaces)


[error] 90-90: trailing spaces

(trailing-spaces)

Ruff
tests/training/test_model_trainer.py

49-49: pytest.raises(Exception) should be considered evil

(B017)

tests/architectures/test_model.py

102-102: pytest.raises(Exception) should be considered evil

(B017)

sleap_nn/training/model_trainer.py

338-339: Use a single if statement instead of nested if statements

(SIM102)


338-338: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)


343-344: Use a single if statement instead of nested if statements

(SIM102)


343-343: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

Markdownlint
docs/config.md

16-16: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


17-17: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


18-18: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


28-28: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


29-29: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


30-30: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


31-31: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


32-32: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


33-33: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


34-34: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


35-35: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


36-36: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


37-37: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


38-38: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


39-39: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


40-40: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


41-41: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


42-42: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


43-43: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


44-44: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


45-45: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


46-46: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


47-47: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


48-48: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


49-49: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


50-50: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


51-51: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


52-52: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


53-53: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


54-54: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


55-55: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


56-56: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


57-57: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


58-58: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


61-61: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


62-62: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


63-63: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


64-64: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


65-65: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


66-66: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


67-67: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


68-68: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


69-69: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


71-71: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


73-73: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


74-74: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


78-78: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


79-79: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


80-80: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


81-81: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


82-82: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


83-83: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


84-84: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


85-85: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


86-86: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


87-87: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


88-88: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


89-89: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


90-90: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


91-91: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


95-95: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


96-96: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


97-97: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


100-100: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


101-101: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


102-102: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


103-103: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


104-104: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


105-105: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


106-106: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


107-107: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


111-111: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


112-112: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


113-113: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


114-114: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


115-115: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


116-116: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


117-117: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


118-118: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


119-119: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


120-120: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


121-121: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


122-122: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


123-123: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


124-124: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


125-125: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


126-126: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


127-127: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


128-128: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


129-129: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


130-130: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


131-131: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


132-132: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


133-133: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


134-134: Expected: 6; Actual: 12
Unordered list indentation

(MD007, ul-indent)


135-135: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


136-136: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


137-137: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


138-138: Expected: 8; Actual: 16
Unordered list indentation

(MD007, ul-indent)


48-48: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


48-48: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


49-49: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


49-49: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


159-159: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)

LanguageTool
docs/config.md

[grammar] ~48-~48: Articles like ‘a’ are rarely followed by punctuation. A word may be missing after ‘a’, or the punctuation mark may not be necessary.
Context: ...lation. For example, if translate_width=a, then horizontal shift is randomly sampl...

(THE_PUNCT)


[grammar] ~49-~49: Articles like ‘a’ are rarely followed by punctuation. A word may be missing after ‘a’, or the punctuation mark may not be necessary.
Context: ...ation. For example, if translate_height=a, then vertical shift is randomly sampled...

(THE_PUNCT)


[uncategorized] ~60-~60: Loose punctuation mark.
Context: ...otherwise for default. - model_config: - init_weight: (str) model weigh...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~73-~73: This phrase might be redundant. Consider either removing or replacing the adjective ‘additional’.
Context: ... - middle_block: (bool) If True, add an additional block at the end of the encoder. default: Tru...

(ADD_AN_ADDITIONAL)


[uncategorized] ~75-~75: Possible missing comma found.
Context: ... for upsampling. Interpolation is faster but transposed convolutions may be ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~92-~92: Possible missing comma found.
Context: ... for upsampling. Interpolation is faster but transposed convolutions may be ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~97-~97: Loose punctuation mark.
Context: ...se"]. Default: "tiny". - arch: Dictionary of embed dimension, depths a...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~108-~108: Possible missing comma found.
Context: ... for upsampling. Interpolation is faster but transposed convolutions may be ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~114-~114: Did you mean “provides” or “provided”?
Context: ...Labels` file can be used directly. Else provide text name of the body parts (nodes) tha...

(NNP_VBP_TO_VBZ)


[uncategorized] ~115-~115: Possible missing comma found.
Context: ...space. Larger values are easier to learn but are less precise with respect to the pe...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~115-~115: ‘with respect to’ might be wordy. Consider a shorter alternative.
Context: ...re easier to learn but are less precise with respect to the peak coordinate. This spread is in ...

(EN_WORDINESS_PREMIUM_WITH_RESPECT_TO)


[uncategorized] ~119-~119: Possible missing comma found.
Context: ...can significantly improve topdown model accuracy as they benefit from a consistent geome...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~120-~120: Possible missing comma found.
Context: ...space. Larger values are easier to learn but are less precise with respect to the pe...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~120-~120: ‘with respect to’ might be wordy. Consider a shorter alternative.
Context: ...re easier to learn but are less precise with respect to the peak coordinate. This spread is in ...

(EN_WORDINESS_PREMIUM_WITH_RESPECT_TO)


[uncategorized] ~124-~124: Did you mean “provides” or “provided”?
Context: ...Labels` file can be used directly. Else provide text name of the body parts (nodes) tha...

(NNP_VBP_TO_VBZ)


[uncategorized] ~125-~125: Possible missing comma found.
Context: ...can significantly improve topdown model accuracy as they benefit from a consistent geome...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~126-~126: Possible missing comma found.
Context: ...space. Larger values are easier to learn but are less precise with respect to the pe...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~126-~126: ‘with respect to’ might be wordy. Consider a shorter alternative.
Context: ...re easier to learn but are less precise with respect to the peak coordinate. This spread is in ...

(EN_WORDINESS_PREMIUM_WITH_RESPECT_TO)


[uncategorized] ~130-~130: Did you mean “provides” or “provided”?
Context: ...Labels` file can be used directly. Else provide text name of the body parts (nodes) tha...

(NNP_VBP_TO_VBZ)


[uncategorized] ~131-~131: Possible missing comma found.
Context: ...space. Larger values are easier to learn but are less precise with respect to the pe...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~131-~131: ‘with respect to’ might be wordy. Consider a shorter alternative.
Context: ...re easier to learn but are less precise with respect to the peak coordinate. This spread is in ...

(EN_WORDINESS_PREMIUM_WITH_RESPECT_TO)


[uncategorized] ~136-~136: Possible missing comma found.
Context: ...space. Larger values are easier to learn but are less precise with respect to the pe...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~136-~136: ‘with respect to’ might be wordy. Consider a shorter alternative.
Context: ...re easier to learn but are less precise with respect to the peak coordinate. This spread is in ...

(EN_WORDINESS_PREMIUM_WITH_RESPECT_TO)

Additional comments not posted (85)
tests/assets/minimal_instance/initial_config.yaml (3)

3-19: LGTM! Improved clarity in data configuration.

The renaming of label paths and focus on geometric augmentations enhance the clarity and usability of the configuration.


24-35: LGTM! Model configuration adjustments are consistent with performance goals.

The changes to filters_rate, max_stride, and up_interpolate are aligned with improving model performance and efficiency.


61-61: Verify the training strategy with reduced epochs.

Reducing max_epochs from 10 to 1 indicates a shift towards rapid prototyping or testing. Ensure this aligns with the intended training strategy.

tests/assets/minimal_instance_centroid/initial_config.yaml (3)

3-21: LGTM! Improved clarity in data configuration.

The renaming of label paths and focus on geometric augmentations enhance the clarity and usability of the configuration.


25-36: LGTM! Model configuration adjustments are consistent with performance goals.

The changes to filters_rate, max_stride, and up_interpolate are aligned with improving model performance and efficiency.


Line range hint 61-61: LGTM! Trainer configuration aligns with training objectives.

The settings maintain a balance between training duration and model performance.

tests/assets/minimal_instance_bottomup/initial_config.yaml (3)

3-17: LGTM! Improved clarity in data configuration.

The renaming of label paths and focus on geometric augmentations enhance the clarity and usability of the configuration.


21-32: LGTM! Model configuration adjustments are consistent with performance goals.

The changes to filters_rate, max_stride, and up_interpolate are aligned with improving model performance and efficiency.


62-63: Verify the training strategy with adjusted epochs and steps.

The reduction in max_epochs and increase in steps_per_epoch suggest a shift in training strategy. Ensure this aligns with the intended objectives.

tests/assets/minimal_instance/training_config.yaml (4)

3-4: Separation of label paths improves clarity.

Defining train_labels_path and val_labels_path separately enhances the clarity of the data configuration.


35-41: Review changes in backbone configuration.

The adjustments in filters_rate and max_stride might affect model performance and efficiency. Verify that these changes align with the desired outcomes.


13-14: Verify the adequacy of augmentation settings.

The augmentation configuration is minimal. Ensure that these settings are sufficient for the intended data variability and model robustness.


74-74: Verify the reduction in training epochs.

The max_epochs is set to 1, which significantly reduces training time. Confirm that this change is intentional and aligns with the desired training strategy.

tests/assets/minimal_instance_centroid/training_config.yaml (4)

3-4: Separation of label paths improves clarity.

Defining train_labels_path and val_labels_path separately enhances the clarity of the data configuration.


36-41: Review changes in backbone configuration.

The adjustments in filters_rate and max_stride might affect model performance and efficiency. Verify that these changes align with the desired outcomes.


Line range hint 74-74: Verify alignment of training epochs with project goals.

The max_epochs is set to 10, which is a typical setting for training. Ensure that this aligns with the desired training strategy and project goals.


10-11: Verify the adequacy of augmentation settings.

The augmentation configuration is minimal. Ensure that these settings are sufficient for the intended data variability and model robustness.

tests/assets/minimal_instance_bottomup/training_config.yaml (4)

3-4: Separation of label paths improves clarity.

Defining train_labels_path and val_labels_path separately enhances the clarity of the data configuration.


32-38: Review changes in backbone configuration.

The adjustments in filters_rate and max_stride might affect model performance and efficiency. Verify that these changes align with the desired outcomes.


77-78: Verify alignment of training steps and epochs with project goals.

The steps_per_epoch is set to 100, and max_epochs is set to 10. Ensure that these settings align with the desired training strategy and project goals.


10-11: Verify the adequacy of augmentation settings.

The augmentation configuration is minimal. Ensure that these settings are sufficient for the intended data variability and model robustness.

Verification successful

Augmentation settings are adequately integrated.

The augmentation_config is utilized in various parts of the codebase, including the main data processing pipeline (sleap_nn/data/pipelines.py). This indicates that the settings are applied effectively to ensure data variability and model robustness.

  • Files with relevant usage:
    • sleap_nn/data/pipelines.py
    • Various YAML configuration files in tests/assets/ and docs/
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and impact of augmentation settings in the codebase.

# Test: Search for augmentation settings usage. Expect: Occurrences of augmentation settings in relevant scripts.
rg --type yaml --type py --type ipynb 'augmentation_config'

Length of output: 89


Script:

#!/bin/bash
# Description: Verify the usage and impact of augmentation settings in the codebase.

# Test: Search for augmentation settings usage in YAML and Python files.
rg --type yaml --type py 'augmentation_config'

Length of output: 4220

docs/config_topdown_centered_instance.yaml (3)

25-25: Confirm backbone type and configuration.

The backbone_type is set to unet. Ensure this is the intended backbone for your model architecture.

Verification successful

Backbone type is correctly set to unet.

The backbone_type: unet is consistently used across multiple configuration files, indicating it is the intended backbone for the model architecture. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the backbone type and configuration.

# Test: Check if the backbone type is correctly specified. Expect: The backbone type should be `unet`.
rg --type yaml "backbone_type: unet"

Length of output: 670


5-5: Remove trailing spaces.

Trailing spaces are present on this line.

-    max_width: 
+    max_width:

Likely invalid or redundant comment.


13-13: Ensure augmentation settings align with training objectives.

The use_augmentations_train flag is set to true. Ensure that this aligns with your training objectives and that the augmentation settings are optimal.

docs/config_bottomup.yaml (3)

87-87: Verify device and accelerator settings.

The trainer_accelerator is set to cpu. Ensure that this aligns with your available hardware and training objectives.

Verification successful

Device and Accelerator Settings Verified

The trainer_accelerator is consistently set to cpu across multiple configuration files, indicating an intentional setup. Ensure this aligns with your hardware and training objectives.

  • docs/config_bottomup.yaml
  • Various test configuration files
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the device and accelerator settings.

# Test: Check if the trainer accelerator is correctly specified. Expect: The trainer accelerator should be `cpu`.
rg --type yaml "trainer_accelerator: cpu"

Length of output: 597


22-22: Confirm backbone type and configuration.

The backbone_type is set to unet. Ensure this is the intended backbone for your model architecture.

Verification successful

Backbone Type Confirmed as 'unet'

The backbone_type is correctly specified as unet in multiple configuration files, including docs/config_bottomup.yaml. This consistency indicates it is the intended backbone for your model architecture. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the backbone type and configuration.

# Test: Check if the backbone type is correctly specified. Expect: The backbone type should be `unet`.
rg --type yaml "backbone_type: unet"

Length of output: 670


10-10: Ensure augmentation settings align with training objectives.

The use_augmentations_train flag is set to true. Ensure that this aligns with your training objectives and that the augmentation settings are optimal.

tests/inference/test_bottomup.py (3)

42-45: Confirm configuration access updates.

The access to configuration values has been updated. Ensure these changes are consistent with the new configuration structure.

Verification successful

Configuration Access Verified

The access to configuration values in tests/inference/test_bottomup.py is consistent with the new structure, as similar patterns are found across multiple files in the codebase.

  • sleap_nn/training/model_trainer.py
  • sleap_nn/inference/predictors.py
  • tests/training/test_model_trainer.py

This confirms that the updates are correctly implemented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the updated configuration access in the test file.

# Test: Check if the access to configuration values is correctly updated. Expect: Access should be consistent with the new structure.
rg --type python "head_configs.bottomup" -A 2

Length of output: 76


Script:

#!/bin/bash
# Description: Verify the updated configuration access in the test file.

# Test: Check if the access to configuration values is correctly updated. Expect: Access should be consistent with the new structure.
rg --type py "head_configs.bottomup" -A 2

Length of output: 4115


17-22: Ensure updated configuration paths are correct.

The configuration paths have been updated. Verify that these updates align with the new configuration structure.


31-34: Verify model initialization parameters.

The BottomUpModel initialization now includes skeletons=None and model_type="bottomup". Ensure these parameters are correct and necessary.

docs/config_centroid.yaml (3)

3-41: LGTM! Improved clarity and organization.

The changes in the data_config section enhance clarity and usability by renaming and restructuring parameters.

Tools
yamllint

[error] 6-6: trailing spaces

(trailing-spaces)


[error] 7-7: trailing spaces

(trailing-spaces)


Line range hint 45-95:
LGTM! Simplified model configuration.

The changes in the model_config section improve accessibility by simplifying the structure.

Tools
yamllint

[error] 6-6: trailing spaces

(trailing-spaces)


[error] 7-7: trailing spaces

(trailing-spaces)


[warning] 47-47: wrong indentation: expected 4 but found 6

(indentation)


[error] 54-54: trailing spaces

(trailing-spaces)


Line range hint 97-143:
LGTM! Consistent restructuring.

The changes in the trainer_config section are consistent with the overall restructuring and enhance clarity.

Tools
yamllint

[error] 117-117: trailing spaces

(trailing-spaces)

tests/inference/test_single_instance.py (1)

Line range hint 18-102:
LGTM! Enhanced configuration and preprocessing.

The changes improve the clarity and functionality of the test by centralizing configuration handling and enhancing the data preprocessing pipeline.

tests/fixtures/datasets.py (1)

Line range hint 52-143:
LGTM! Simplified configuration structure.

The changes enhance clarity and usability by simplifying the configuration structure and improving naming conventions.

sleap_nn/architectures/model.py (1)

Line range hint 117-177:
Verify the integration of new parameters.

Ensure that the model_type and backbone_type parameters are correctly integrated and utilized throughout the Model class and its methods.

Verification successful

Integration of model_type and backbone_type is correct.

The model_type and backbone_type parameters are properly integrated and utilized within the Model class. They are used in the constructor and passed to relevant functions, ensuring they are part of the model's configuration and initialization process. No issues were found with their integration.

  • model_type is used in the get_head function.
  • backbone_type is used in the get_backbone function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `model_type` and `backbone_type` in the `Model` class.

# Test: Search for the usage of `model_type` and `backbone_type` in the `Model` class.
ast-grep --lang python --pattern $'class Model(nn.Module) {
  $$$
  def __init__($_, backbone_type: str, $$$, model_type: str):
    $$$
  }
}'

Length of output: 672


Script:

#!/bin/bash
# Description: Search for occurrences of `model_type` and `backbone_type` within the `Model` class.

# Locate the file containing the `Model` class.
fd -e py | xargs rg -A 10 'class Model'

# Search for `model_type` and `backbone_type` usage in the located file.
rg 'model_type|backbone_type' sleap_nn/architectures/model.py

Length of output: 2976

tests/inference/test_topdown.py (4)

31-34: Verify consistency of model_type usage.

Ensure that the addition of the model_type parameter in load_from_checkpoint is consistent with other parts of the codebase where models are initialized or loaded.


318-321: Verify consistency of model_type usage in tests.

Ensure that the addition of model_type in model loading calls is consistent across all test functions and does not affect their logic.


74-81: Verify the impact of removing part_names.

Ensure that the removal of part_names from the confmaps head configuration does not affect the functionality of the test_centroid_inference_model test.


179-191: Verify integration of configuration updates.

Ensure that the configuration updates and the addition of model_type in model loading are correctly integrated and do not introduce inconsistencies.

Verification successful

Integration of model_type is consistent and correct.

The use of model_type in load_from_checkpoint is consistently applied across the codebase, aligning with the refactoring efforts and standard practices. No inconsistencies were found.

  • Instances of load_from_checkpoint with model_type are found in various files, confirming its standard usage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of configuration updates and `model_type` in model loading.

# Test: Search for the usage of `model_type` and configuration updates in the codebase.
rg --type python -A 3 $'load_from_checkpoint' | rg 'model_type'

Length of output: 91


Script:

#!/bin/bash
# Description: Verify the integration of configuration updates and `model_type` in model loading.

# Test: Search for the usage of `model_type` in the `load_from_checkpoint` function across Python files.
rg 'load_from_checkpoint' --type py -A 3 | rg 'model_type'

Length of output: 56


Script:

#!/bin/bash
# Description: Broaden the search for the integration of `model_type` in the codebase.

# Search for `load_from_checkpoint` with more context to capture any surrounding configuration.
rg 'load_from_checkpoint' --type py -A 10

# Search separately for `model_type` to see if it appears in relevant contexts.
rg 'model_type' --type py -A 3

Length of output: 29711

sleap_nn/data/augmentation.py (2)

157-215: LGTM! The parameter changes improve flexibility and clarity.

The renaming and type adjustments for parameters like scale, translate_width, translate_height, etc., enhance the augmenter's usability.


Line range hint 225-292:
Verify consistency of parameter usage in augmentation logic.

Ensure that the updated parameters are correctly used in the augmentation logic and that the intended functionality is preserved.

Verification successful

Parameter Usage Verified in Augmentation Logic

The parameters related to transformations such as scale, translate, noise, contrast, brightness, and erase are correctly used in the augmentation logic. The intended functionality appears to be preserved, as these parameters are consistently applied within the K.augmentation methods.

  • File: sleap_nn/data/augmentation.py
    • translate=(self.translate_width, self.translate_height)
    • scale=self.scale
    • mean=self.gaussian_noise_mean
    • std=self.gaussian_noise_std
    • contrast=(self.contrast_min, self.contrast_max)
    • brightness=self.brightness
    • scale=(self.erase_scale_min, self.erase_scale_max)
    • ratio=(self.erase_ratio_min, self.erase_ratio_max)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of updated parameters in the augmentation logic.

# Test: Search for the usage of updated parameters in the `KorniaAugmenter` class.
rg --type python 'K.augmentation' | rg 'scale|translate|noise|contrast|brightness|erase'

Length of output: 119


Script:

#!/bin/bash
# Description: Verify the usage of updated parameters in the augmentation logic.

# Test: Search for the usage of updated parameters in the augmentation logic.
rg 'K.augmentation' | rg 'scale|translate|noise|contrast|brightness|erase'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the usage of updated parameters in the augmentation logic with more context.

# Test: Search for the usage of updated parameters in the augmentation logic with additional context lines.
rg 'K.augmentation' -A 5 | rg 'scale|translate|noise|contrast|brightness|erase'

Length of output: 1076

tests/inference/test_predictors.py (4)

106-106: LGTM! Verify downstream support for list structure.

The change to use a list for peak_threshold is approved. Ensure that all downstream code can handle this list structure correctly.


168-175: Configuration update is well-structured.

The changes to manage the single_instance configuration are clear and consistent with best practices.


226-233: Configuration update is well-structured.

The changes to manage the VideoReader configuration are clear and consistent with best practices.


78-78: LGTM! Verify downstream support for list structure.

The change to use a list for peak_threshold is approved. Ensure that all downstream code can handle this list structure correctly.

Verification successful

Downstream Support for peak_threshold List Structure Verified

The codebase includes handling for peak_threshold as both a float and a list, indicating that the downstream code is prepared to accommodate the list structure. No further issues were found.

  • sleap_nn/inference/predictors.py: Contains logic to handle peak_threshold as a list.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify downstream support for list structure in `peak_threshold`.

# Test: Search for usage of `peak_threshold`. Expect: Handling of list structure.
rg --type python -A 5 $'peak_threshold'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify downstream support for list structure in `peak_threshold`.

# Test: Search for usage of `peak_threshold`. Expect: Handling of list structure.
rg -t py -A 5 'peak_threshold'

Length of output: 34169

sleap_nn/data/pipelines.py (4)

46-55: Flexible augmentation control is well-implemented.

The introduction of the use_augmentations parameter enhances flexibility while maintaining backward compatibility.


69-72: Augmentation logic refactoring is effective.

The refactoring of augmentation logic into a single conditional block enhances readability and maintainability.


150-198: Consistent augmentation handling across pipelines.

The changes maintain consistency across different pipeline implementations, ensuring uniform behavior.


Line range hint 244-300: Consistent augmentation handling across pipelines.

The changes maintain consistency across different pipeline implementations, ensuring uniform behavior.

tests/training/test_model_trainer.py (7)

52-58: Single instance pipeline test is well-structured.

The test correctly applies the single instance configuration, ensuring the intended behavior.


63-67: Centroid pipeline test is well-structured.

The test correctly applies the centroid configuration, ensuring the intended behavior.


194-200: Single instance model configuration is accurate.

The removal of irrelevant configurations ensures test accuracy.


210-215: Centroid model configuration is accurate.

The removal of irrelevant configurations ensures test accuracy.


238-248: Bottom-up model configuration is accurate.

The removal of irrelevant configurations ensures test accuracy.


337-345: Centroid model test configuration is accurate.

The test applies the correct configuration, ensuring the intended behavior.


366-379: Single instance model test configuration is accurate.

The test applies the correct configuration, ensuring the intended behavior.

tests/architectures/test_model.py (9)

15-24: Configuration restructuring approved.

The restructuring of configuration dictionaries for the backbone models improves clarity and maintainability.

Also applies to: 29-30, 38-46, 51-52, 63-72, 77-78


90-95: Configuration restructuring approved.

The restructuring of configuration dictionaries for the head models improves clarity and maintainability.

Also applies to: 99-100


111-120: Configuration restructuring approved.

The restructuring of configuration dictionaries for the UNet model improves clarity and maintainability.

Also applies to: 126-131, 136-140, 160-169, 175-180, 185-189, 209-218, 224-229, 234-238


261-269: Configuration restructuring approved.

The restructuring of configuration dictionaries for the ConvNext model improves clarity and maintainability.

Also applies to: 275-280, 285-289, 328-336, 342-347, 352-356, 395-403, 409-414, 419-423


466-475: Configuration restructuring approved.

The restructuring of configuration dictionaries for the Swin Transformer model improves clarity and maintainability.

Also applies to: 481-486, 491-495, 534-544, 550-555, 560-564


58-58: Verify the change in error handling.

The error handling has been generalized from KeyError to Exception. Ensure that this change aligns with the expected error types raised by get_backbone.

Also applies to: 84-84


Line range hint 293-304:
Verify the assertions for model outputs.

Ensure that the assertions for model outputs are consistent with the expected shapes and types, especially after configuration changes.

Also applies to: 322-323, 360-371, 389-390, 427-438, 456-457


Line range hint 144-155:
Verify the assertions for model outputs.

Ensure that the assertions for model outputs are consistent with the expected shapes and types, especially after configuration changes.

Also applies to: 193-204, 242-253

Verification successful

Assertions for model outputs are consistent with expected shapes and types. The forward method in the Model class processes inputs and generates outputs using heads and head_layers, which aligns with the dictionary structure asserted in the tests. The U-Net architecture contributes to the processing but doesn't directly affect the output structure tested.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the expected output shapes and types for UNet model.

# Test: Search for the `Model` class definition and check for output specifications.
rg --type python 'class Model'

Length of output: 63


Script:

#!/bin/bash
# Correcting the previous command to search for the Model class or relevant definitions in Python files.

# Search for the Model class definition in Python files.
rg 'class Model' --glob '*.py' -A 10

# Search for any functions or methods that might define the model's output.
rg 'def ' --glob '*.py' -A 5 | grep -i 'output\|forward'

Length of output: 11279


Script:

#!/bin/bash
# Search for the forward method in the Model class to verify output shapes and types.

# Inspect the forward method in the Model class.
rg 'def forward' sleap_nn/architectures/model.py -A 10

# Inspect the forward method in the U-Net architecture.
rg 'def forward' sleap_nn/architectures/unet.py -A 10

Length of output: 950


Line range hint 499-510:
Verify the assertions for model outputs.

Ensure that the assertions for model outputs are consistent with the expected shapes and types, especially after configuration changes.

Also applies to: 528-529, 568-579, 597-598

Verification successful

Assertions for model outputs are consistent with expected configurations.

The SingleInstanceConfmapsHead class's channels method returns the number of channels based on the part_names, aligning with the test's expected output shape of (1, 13, 192, 192). This confirms that the assertions in the test are consistent with the model's expected output configurations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the expected output shapes and types for Swin Transformer model.

# Test: Search for the `Model` class definition and check for output specifications.
rg --type python 'class Model'

Length of output: 63


Script:

#!/bin/bash
# Search for all class definitions in the codebase to identify relevant model classes.
rg --pcre2 --type py 'class\s+\w+'

Length of output: 10031


Script:

#!/bin/bash
# Search for the implementation details of the SwinTWrapper and SingleInstanceConfmapsHead classes.
ast-grep --lang python --pattern 'class SwinTWrapper { $$$ }'
ast-grep --lang python --pattern 'class SingleInstanceConfmapsHead { $$$ }'

Length of output: 1053


Script:

#!/bin/bash
# Correct the pattern to search for the SwinTWrapper class definition and its contents.
ast-grep --lang python --pattern 'class SwinTWrapper { $_$ }'
# Correct the pattern to search for the SingleInstanceConfmapsHead class definition and its contents.
ast-grep --lang python --pattern 'class SingleInstanceConfmapsHead { $_$ }'

Length of output: 831


Script:

#!/bin/bash
# Search for the SwinTWrapper class definition and its methods.
rg --type py 'class SwinTWrapper|def ' sleap_nn/architectures/swint.py -A 10

# Search for the SingleInstanceConfmapsHead class definition and its methods.
rg --type py 'class SingleInstanceConfmapsHead|def ' sleap_nn/architectures/heads.py -A 10

Length of output: 12887

docs/config.md (3)

16-17: Parameter restructuring approved.

The restructuring and renaming of parameters in the data_config section enhance clarity and usability.

Also applies to: 28-29, 30-31

Tools
Markdownlint

16-16: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


17-17: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


63-64: Parameter restructuring approved.

The restructuring and standardization of parameters in the model_config section enhance consistency and configurability.

Also applies to: 80-81, 95-96, 111-112

Tools
Markdownlint

63-63: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


64-64: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


159-159: Parameter restructuring approved.

The restructuring and conditional inclusion of parameters in the trainer_config section enhance clarity and functionality.

Tools
Markdownlint

159-159: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)

tests/data/test_pipelines.py (8)

102-109: Configuration restructuring approved.

The restructuring of configuration dictionaries and introduction of use_augmentations_train improve clarity and flexibility.

Also applies to: 148-156, 228-236


315-321: Configuration restructuring approved.

The restructuring of configuration dictionaries and introduction of use_augmentations_train improve clarity and flexibility.

Also applies to: 358-366


437-443: Configuration restructuring approved.

The restructuring of configuration dictionaries and introduction of use_augmentations_train improve clarity and flexibility.

Also applies to: 477-485


554-560: Configuration restructuring approved.

The restructuring of configuration dictionaries and introduction of use_augmentations_train improve clarity and flexibility.

Also applies to: 602-608, 647-655, 727-735


119-122: Verify the assertions for pipeline outputs.

Ensure that the assertions for pipeline outputs are consistent with the expected shapes and keys, especially after configuration changes.

Also applies to: 197-200, 277-280

Verification successful

Assertions for pipeline outputs are verified.

The test file tests/data/test_pipelines.py contains assertions that verify the expected output shapes and keys for the pipeline, ensuring consistency with configuration changes. The assertions cover various scenarios and configurations.

  • The TopdownConfmapsPipeline class is defined in sleap_nn/data/pipelines.py.
  • Assertions in tests/data/test_pipelines.py confirm expected output shapes and keys for multiple pipeline tests.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the expected output shapes and keys for TopdownConfmapsPipeline.

# Test: Search for the `TopdownConfmapsPipeline` class definition and check for output specifications.
rg --type python 'class TopdownConfmapsPipeline'

Length of output: 81


Script:

#!/bin/bash
# Correct the file type for Python and search for the `TopdownConfmapsPipeline` class definition.
rg --type py 'class TopdownConfmapsPipeline'

# Search for test assertions related to pipeline outputs in the test file.
rg --type py 'assert' tests/data/test_pipelines.py -A 5

Length of output: 5286


575-578: Verify the assertions for pipeline outputs.

Ensure that the assertions for pipeline outputs are consistent with the expected shapes and keys, especially after configuration changes.

Also applies to: 620-623, 699-702, 779-782

Verification successful

Assertions for Pipeline Outputs are Verified

The test_bottomuppipeline function includes assertions that verify the expected keys and shapes of the pipeline outputs. The assertions check for the presence of specific keys and validate the shapes of the "image", "confidence_maps", and "part_affinity_fields" outputs, ensuring consistency with the expected configuration.

  • Keys Asserted: image, video_idx, frame_idx, confidence_maps, orig_size, num_instances, scale, part_affinity_fields.
  • Shape Assertions:
    • sample["image"].shape == (1, 1, 384, 384)
    • sample["confidence_maps"].shape == (1, 2, 192, 192)
    • sample["part_affinity_fields"].shape == (96, 96, 2)

These assertions confirm that the pipeline outputs are consistent with the expected configuration.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the expected output shapes and keys for BottomUpPipeline.

# Test: Search for the `BottomUpPipeline` class definition and check for output specifications.
rg --type python 'class BottomUpPipeline'

Length of output: 74


Script:

#!/bin/bash
# Corrected search for the `BottomUpPipeline` class definition and related methods.

# Find all Python files and search for the class definition
rg 'class BottomUpPipeline' --glob '*.py' -A 10

# Search for methods that might define or use the pipeline
rg 'def ' --glob '*.py' -A 5 | rg 'pipeline' -A 5

Length of output: 9462


Script:

#!/bin/bash
# Extract the `test_bottomuppipeline` function and its assertions from the test file.

# Search for the `test_bottomuppipeline` function definition and its content
rg 'def test_bottomuppipeline' tests/data/test_pipelines.py -A 20

Length of output: 706


Script:

#!/bin/bash
# Extend the search to capture more lines from the `test_bottomuppipeline` function.

# Search for the `test_bottomuppipeline` function definition and capture more lines to check for assertions
rg 'def test_bottomuppipeline' tests/data/test_pipelines.py -A 50

Length of output: 1620


453-456: Verify the assertions for pipeline outputs.

Ensure that the assertions for pipeline outputs are consistent with the expected shapes and keys, especially after configuration changes.

Also applies to: 526-529


334-337: Verify the assertions for pipeline outputs.

Ensure that the assertions for pipeline outputs are consistent with the expected shapes and keys, especially after configuration changes.

Also applies to: 409-412

sleap_nn/training/model_trainer.py (5)

546-552: Ensure consistency in constructor parameters across model classes.

The model_type parameter should be consistently documented and used across all model classes.


617-623: Ensure consistency in constructor parameters across model classes.

The model_type parameter should be consistently documented and used across all model classes.


688-694: Ensure consistency in constructor parameters across model classes.

The model_type parameter should be consistently documented and used across all model classes.


86-124: Ensure model_type is valid before using it.

The code assumes that model_type will always be set correctly. Consider adding a validation step to ensure that model_type is one of the expected values before proceeding.


475-485: Ensure self.device is initialized.

The self.device attribute is used in the forward method, but its initialization is not shown in the provided code. Ensure that it is correctly initialized elsewhere.

sleap_nn/inference/predictors.py (3)

415-421: Handle list type for peak_threshold consistently.

Ensure that both elements of the peak_threshold list are used correctly for their respective models.


835-841: Ensure peak_threshold is correctly utilized.

The peak_threshold should be correctly handled and documented to ensure it aligns with the intended functionality.


Line range hint 1138-1163: Ensure peak_threshold is correctly utilized.

The peak_threshold should be correctly handled and documented to ensure it aligns with the intended functionality.

docs/config_centroid.yaml Outdated Show resolved Hide resolved
docs/config_centroid.yaml Outdated Show resolved Hide resolved
sleap_nn/architectures/model.py Outdated Show resolved Hide resolved
docs/config_topdown_centered_instance.yaml Outdated Show resolved Hide resolved
docs/config_topdown_centered_instance.yaml Outdated Show resolved Hide resolved
docs/config_bottomup.yaml Outdated Show resolved Hide resolved
docs/config_bottomup.yaml Outdated Show resolved Hide resolved
docs/config_bottomup.yaml Outdated Show resolved Hide resolved
tests/training/test_model_trainer.py Outdated Show resolved Hide resolved
tests/architectures/test_model.py Outdated Show resolved Hide resolved
@gitttt-1234 gitttt-1234 changed the base branch from main to divya/refactor-aug-config August 8, 2024 00:29
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 97.61905% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.96%. Comparing base (f093ce2) to head (f9462b3).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
sleap_nn/inference/predictors.py 97.14% 1 Missing ⚠️
sleap_nn/inference/utils.py 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
+ Coverage   96.64%   97.96%   +1.31%     
==========================================
  Files          23       30       +7     
  Lines        1818     2797     +979     
==========================================
+ Hits         1757     2740     +983     
+ Misses         61       57       -4     

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

Base automatically changed from divya/refactor-aug-config to main August 14, 2024 20:25
@talmo talmo changed the title Greg/minimalinstances Add minimal pretrained checkpoints for tests Aug 14, 2024
sleap_nn/inference/paf_grouping.py Outdated Show resolved Hide resolved
@gitttt-1234 gitttt-1234 linked an issue Aug 15, 2024 that may be closed by this pull request
Copy link
Contributor

@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: 1

Outside diff range, codebase verification and nitpick comments (3)
tests/inference/test_utils.py (1)

17-29: New test function test_interp1d is well-structured.

The test function effectively validates the interp1d function with both 1D and 2D inputs. It checks the output shapes, which is crucial for ensuring that the interpolation behaves as expected. Consider adding more assertions to validate the correctness of the interpolated values.

+    assert torch.allclose(yq, expected_values, atol=1e-5)

This would require defining expected_values based on known correct results.

sleap_nn/inference/utils.py (1)

56-158: New function interp1d is well-implemented.

The function provides a robust implementation of linear 1-D interpolation with PyTorch tensors. It includes detailed assertions and handles device management effectively. Consider adding more detailed error messages for the assertions to improve debugging.

-        assert len(vec.shape) <= 2, "interp1d: all inputs must be " "at most 2-D."
+        assert len(vec.shape) <= 2, f"interp1d: {name} must be at most 2-D, but got shape {vec.shape}."
tests/data/test_pipelines.py (1)

Mismatch in Expected Output Keys for KeyFilter

The addition of "original_image" to the expected keys in the test does not align with the current implementation of the KeyFilter. The key is not present in the expected output keys in the codebase. Please review the test logic and ensure it matches the intended functionality.

  • File: tests/data/test_pipelines.py
  • Relevant Code: No occurrence of "original_image" in the expected keys for KeyFilter.
Analysis chain

Line range hint 14-14: Verify the correctness of expected output keys.

The addition of "original_image" to the expected keys should be verified to ensure it aligns with the expected output of the KeyFilter pipeline.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the KeyFilter pipeline correctly outputs the "original_image" key.

# Test: Search for KeyFilter usage. Expect: Occurrences of "original_image" in the output.
rg --type python 'KeyFilter' -A 10

Length of output: 65


Script:

#!/bin/bash
# Description: Verify that the KeyFilter pipeline correctly outputs the "original_image" key.

# Test: Search for KeyFilter usage. Expect: Occurrences of "original_image" in the output.
rg --type py 'KeyFilter' -A 10

Length of output: 8000

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 445bd4d and 1a19663.

Files selected for processing (14)
  • sleap_nn/data/instance_cropping.py (1 hunks)
  • sleap_nn/data/pipelines.py (10 hunks)
  • sleap_nn/data/resizing.py (1 hunks)
  • sleap_nn/inference/paf_grouping.py (6 hunks)
  • sleap_nn/inference/predictors.py (32 hunks)
  • sleap_nn/inference/utils.py (2 hunks)
  • tests/data/test_instance_cropping.py (2 hunks)
  • tests/data/test_pipelines.py (37 hunks)
  • tests/data/test_resizing.py (1 hunks)
  • tests/inference/test_paf_grouping.py (1 hunks)
  • tests/inference/test_predictors.py (13 hunks)
  • tests/inference/test_single_instance.py (3 hunks)
  • tests/inference/test_topdown.py (6 hunks)
  • tests/inference/test_utils.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • tests/data/test_resizing.py
Additional comments not posted (40)
tests/inference/test_utils.py (1)

2-2: Import of torch is appropriate.

The addition of the torch import is necessary for the tensor operations in the new test function.

tests/data/test_instance_cropping.py (1)

47-47: Modification of gt_sample_keys requires verification.

The removal of "image" and "scale" from gt_sample_keys suggests a change in the expected sample structure. Verify that these keys are indeed no longer relevant or necessary for the test's validation logic.

Verification successful

Modification of gt_sample_keys is verified.

The removal of "image" and "scale" from gt_sample_keys aligns with the current test logic, which asserts the number of keys in the sample. If the tests pass, it confirms that these keys are no longer necessary.

  • tests/data/test_instance_cropping.py: Verified change in gt_sample_keys.
  • tests/data/test_pipelines.py: Consistent usage pattern observed.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `gt_sample_keys` and ensure that the removed keys are not required.

# Test: Search for the usage of `gt_sample_keys` in the repository to confirm the changes.
rg --type python 'gt_sample_keys'

Length of output: 64


Script:

#!/bin/bash
# Description: Verify the usage of `gt_sample_keys` and ensure that the removed keys are not required.

# Test: Search for the usage of `gt_sample_keys` in the repository to confirm the changes.
rg --type py 'gt_sample_keys'

Length of output: 3117

tests/inference/test_single_instance.py (2)

17-31: Streamlined configuration management.

Loading the configuration directly within the function improves clarity and maintainability. Ensure that this change aligns with the intended testing scenarios.


56-59: Addition of Resizer and PadToStride enhances preprocessing.

These components improve the flexibility of data preprocessing in the inference model testing. Ensure that the scaling and stride padding parameters are correctly set for the intended use cases.

sleap_nn/data/instance_cropping.py (1)

84-84: Deletion of "image" key requires verification.

The removal of the "image" key from the ex dictionary suggests a refinement in data handling. Verify that this change does not impact other parts of the code that may rely on this key.

sleap_nn/data/resizing.py (1)

Line range hint 15-18: Ensure downstream processes do not rely on removed scale key.

The removal of the scale key from the output dictionary in the __iter__ method might affect any downstream processes that previously relied on this information. Ensure that this change is intentional and verify that no other parts of the codebase depend on the scale key being present.

tests/inference/test_topdown.py (3)

31-34: Verify correct usage of added parameters in initialize_model.

The addition of skeletons=None and model_type="centered_instance" parameters in the initialize_model function improves flexibility. Ensure that these parameters are correctly utilized and do not conflict with other parts of the codebase.


179-185: Refactor configuration updates for clarity and maintainability.

Similar to previous changes, consider encapsulating these operations in a helper function to improve code clarity and maintainability.

def update_centroid_config(config):
    OmegaConf.update(
        config,
        "model_config.head_configs.centroid",
        config.model_config.head_configs.centered_instance,
    )
    del config.model_config.head_configs.centered_instance
    del config.model_config.head_configs.centroid["confmaps"].part_names

314-317: Verify correct usage of added parameters in test_topdown_inference_model.

The addition of skeletons=None and model_type="centroid" parameters in the CentroidModel.load_from_checkpoint function call improves flexibility. Ensure that these parameters are correctly utilized and do not conflict with other parts of the codebase.

tests/inference/test_predictors.py (8)

57-61: Ensure configuration copy and update logic is correct.

The logic for copying and updating the configuration is crucial for test accuracy. Ensure that the copied configuration is correctly modified and saved without affecting the original configuration.


106-106: Verify impact of peak_threshold parameter change.

The change from a single float to a list for peak_threshold allows for more nuanced control. Verify that this change is compatible with the rest of the codebase and that all relevant functions can handle this new structure.


168-175: Ensure configuration copy and update logic is correct.

Ensure that the configuration copy and update logic is correctly implemented and does not affect the original configuration. This is crucial for maintaining test integrity.


226-233: Ensure configuration copy and update logic is correct.

Ensure that the configuration copy and update logic is correctly implemented and does not affect the original configuration. This is crucial for maintaining test integrity.


278-283: Ensure configuration copy and update logic is correct.

Ensure that the configuration copy and update logic is correctly implemented and does not affect the original configuration. This is crucial for maintaining test integrity.


319-319: Adjust assertion for predicted instances.

The assertion now checks for <= 6 instances instead of == 6, allowing for more flexibility. Ensure that this change aligns with the expected behavior of the test.


373-373: Adjust assertion for predicted instances.

The assertion now checks for <= 6 instances instead of == 6, allowing for more flexibility. Ensure that this change aligns with the expected behavior of the test.


78-78: Verify impact of peak_threshold parameter change.

The change from a single float to a list for peak_threshold allows for more nuanced control. Verify that this change is compatible with the rest of the codebase and that all relevant functions can handle this new structure.

Verification successful

Verification Successful: peak_threshold Parameter Change is Compatible

The change from a float to a list for the peak_threshold parameter is supported in the codebase. The sleap_nn/inference/predictors.py file includes type annotations and logic to handle both float and list types, ensuring compatibility with this change. No further issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility of `peak_threshold` parameter change.

# Test: Search for occurrences of `peak_threshold` in the codebase. Expect: Functions handle list structure.
rg --type python 'peak_threshold'

Length of output: 64


Script:

#!/bin/bash
# Corrected command to search for occurrences of `peak_threshold` in Python files.
rg 'peak_threshold' --glob '*.py' -A 5

Length of output: 34165

sleap_nn/data/pipelines.py (13)

46-55: Verify new use_augmentations parameter functionality.

The introduction of the use_augmentations parameter provides more control over the augmentation process. Ensure that this parameter is correctly integrated and that the logic for applying augmentations is sound.


61-65: Ensure consistency with updated configuration references.

The updates to use self.data_config.preprocessing for parameters ensure consistency with the new configuration structure. Verify that all references are correctly updated and consistent throughout the code.


69-72: Ensure correct application of intensity augmentations.

The logic for applying intensity augmentations should be verified to ensure that it aligns with the intended behavior and configuration settings.


86-89: Ensure correct application of geometric augmentations.

The logic for applying geometric augmentations should be verified to ensure that it aligns with the intended behavior and configuration settings.


148-157: Verify new use_augmentations parameter functionality.

The introduction of the use_augmentations parameter provides more control over the augmentation process. Ensure that this parameter is correctly integrated and that the logic for applying augmentations is sound.


163-167: Ensure consistency with updated configuration references.

The updates to use self.data_config.preprocessing for parameters ensure consistency with the new configuration structure. Verify that all references are correctly updated and consistent throughout the code.


171-196: Ensure correct application of augmentations.

The logic for applying intensity, geometric, and random crop augmentations should be verified to ensure that it aligns with the intended behavior and configuration settings.


241-250: Verify new use_augmentations parameter functionality.

The introduction of the use_augmentations parameter provides more control over the augmentation process. Ensure that this parameter is correctly integrated and that the logic for applying augmentations is sound.


264-268: Ensure consistency with updated configuration references.

The updates to use self.data_config.preprocessing for parameters ensure consistency with the new configuration structure. Verify that all references are correctly updated and consistent throughout the code.


272-296: Ensure correct application of augmentations.

The logic for applying intensity, geometric, and random crop augmentations should be verified to ensure that it aligns with the intended behavior and configuration settings.


342-351: Verify new use_augmentations parameter functionality.

The introduction of the use_augmentations parameter provides more control over the augmentation process. Ensure that this parameter is correctly integrated and that the logic for applying augmentations is sound.


366-370: Ensure consistency with updated configuration references.

The updates to use self.data_config.preprocessing for parameters ensure consistency with the new configuration structure. Verify that all references are correctly updated and consistent throughout the code.


374-399: Ensure correct application of augmentations.

The logic for applying intensity, geometric, and random crop augmentations should be verified to ensure that it aligns with the intended behavior and configuration settings.

tests/inference/test_paf_grouping.py (1)

50-55: Verify integration of new pafs_hw parameter.

The addition of the pafs_hw parameter to the make_line_subs function call enhances its capability. Ensure that this parameter is correctly integrated and that the function behaves as expected with this new input.

tests/data/test_pipelines.py (4)

98-105: Verify consistency of configuration changes.

The changes to augmentation settings and configuration parameters should be consistent with the intended functionality of the TopdownConfmapsPipeline.

Also applies to: 142-180, 220-258


425-431: Verify consistency of configuration changes.

The changes to augmentation settings and configuration parameters should be consistent with the intended functionality of the CentroidConfmapsPipeline.

Also applies to: 464-502

Verification successful

Configuration Changes Verified

The configuration changes to preprocessing and use_augmentations_train in the CentroidConfmapsPipeline are consistent with its intended functionality. The changes are reflected in both the main code and test files, ensuring uniform application.

  • File: tests/data/test_pipelines.py
  • File: sleap_nn/training/model_trainer.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of configuration changes in CentroidConfmapsPipeline.

# Test: Search for configuration usage. Expect: Consistent application of new configuration settings.
rg --type python 'CentroidConfmapsPipeline' -A 10

Length of output: 80


Script:

#!/bin/bash
# Description: Verify the consistency of configuration changes in CentroidConfmapsPipeline.

# Test: Search for configuration usage. Expect: Consistent application of new configuration settings.
rg --type py 'CentroidConfmapsPipeline' -A 10

Length of output: 6207


305-311: Verify consistency of configuration changes.

The changes to augmentation settings and configuration parameters should be consistent with the intended functionality of the SingleInstanceConfmapsPipeline.

Also applies to: 347-385


540-546: Verify consistency of configuration changes.

The changes to augmentation settings and configuration parameters should be consistent with the intended functionality of the BottomUpPipeline.

Also applies to: 587-593, 631-669, 710-748

Verification successful

Configuration Changes Verified

The configuration changes to the BottomUpPipeline, including use_augmentations_train, are consistently applied in the test cases. The updates align with the intended functionality of the pipeline.

  • tests/data/test_pipelines.py: Lines where BottomUpPipeline is instantiated and used.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of configuration changes in BottomUpPipeline.

# Test: Search for configuration usage. Expect: Consistent application of new configuration settings.
rg --type python 'BottomUpPipeline' -A 10

Length of output: 72


Script:

#!/bin/bash
# Description: Verify the consistency of configuration changes in BottomUpPipeline.

# Test: Search for configuration usage. Expect: Consistent application of new configuration settings.
rg 'BottomUpPipeline' -t py -A 10

Length of output: 7733

sleap_nn/inference/paf_grouping.py (2)

282-284: Verify correctness of pafs_hw derivation and usage.

Ensure that pafs_hw is correctly derived from pafs_sample and used consistently with the function's purpose.

Verification successful

Verification successful: Correct derivation and usage of pafs_hw.

The pafs_hw is correctly derived from pafs_sample and used consistently in the get_paf_lines function. The function is adequately tested in tests/inference/test_paf_grouping.py, confirming its expected behavior.

  • tests/inference/test_paf_grouping.py: Contains test cases for get_paf_lines.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `pafs_hw` derivation and usage in get_paf_lines.

# Test: Search for get_paf_lines usage. Expect: Correct derivation and passing of `pafs_hw`.
rg --type python 'get_paf_lines' -A 10

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the correctness of `pafs_hw` derivation and usage in get_paf_lines.

# Test: Search for get_paf_lines usage. Expect: Correct derivation and passing of `pafs_hw`.
rg --type py 'get_paf_lines' -A 10

Length of output: 6077


Line range hint 139-160: Verify correctness of new parameter usage and logic.

The new pafs_hw parameter should be correctly utilized to clip coordinates within the bounds of the PAFs tensor dimensions.

Also applies to: 205-208

sleap_nn/inference/predictors.py (3)

413-419: Verify correctness of threshold application logic.

Ensure that the logic correctly distinguishes and applies the appropriate thresholds for centroid and centered-instance models.

Verification successful

Threshold application logic is correctly implemented.

The logic for handling peak_threshold in the _initialize_inference_model method is correctly distinguishing between list and non-list values, applying them to centroid_peak_threshold and centered_instance_peak_threshold as intended. The method is integrated into the workflow, ensuring proper application of these thresholds.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of threshold application logic in TopDownPredictor.

# Test: Search for _initialize_inference_model usage. Expect: Correct application of thresholds for different model types.
rg --type python '_initialize_inference_model' -A 10

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the correctness of threshold application logic in TopDownPredictor.

# Test: Search for _initialize_inference_model usage. Expect: Correct application of thresholds for different model types.
rg --type py '_initialize_inference_model' -A 10

Length of output: 6993


Line range hint 1423-1475: Verify flexibility of peak_threshold parameter handling.

Ensure that the logic correctly handles both single float and list inputs for peak_threshold, applying the appropriate thresholds for different model types.

Verification successful

peak_threshold Parameter Handling is Correct

The implementation correctly handles both single float and list inputs for the peak_threshold parameter, applying appropriate thresholds for different model types as needed. The logic distinguishes between these input types and processes them accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the flexibility of `peak_threshold` handling in main function.

# Test: Search for main function usage. Expect: Correct handling of both float and list inputs for `peak_threshold`.
rg --type python 'def main' -A 10

Length of output: 66


Script:

#!/bin/bash
# Description: Verify the flexibility of `peak_threshold` handling in main function.

# Test: Search for main function usage. Expect: Correct handling of both float and list inputs for `peak_threshold`.
rg --type py 'def main' -A 10

Length of output: 685


Script:

#!/bin/bash
# Description: Verify the handling of `peak_threshold` within the main function.

# Test: Search for the usage of `peak_threshold` in the main function.
rg --type py 'peak_threshold' -A 10 sleap_nn/inference/predictors.py

Length of output: 15525


Line range hint 86-106: Verify flexibility of peak_threshold parameter handling.

Ensure that the logic correctly handles both single float and list inputs for peak_threshold, applying the appropriate thresholds for different model types.

tests/inference/test_topdown.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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: 21

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1a19663 and ea9dfde.

Files selected for processing (7)
  • tests/assets/minimal_instance/initial_config.yaml (3 hunks)
  • tests/assets/minimal_instance/training_config.yaml (3 hunks)
  • tests/assets/minimal_instance_bottomup/initial_config.yaml (4 hunks)
  • tests/assets/minimal_instance_bottomup/training_config.yaml (3 hunks)
  • tests/assets/minimal_instance_centroid/initial_config.yaml (3 hunks)
  • tests/assets/minimal_instance_centroid/training_config.yaml (3 hunks)
  • tests/inference/test_single_instance.py (3 hunks)
Additional context used
yamllint
tests/assets/minimal_instance/initial_config.yaml

[error] 6-6: duplication of key "train_labels_path" in mapping

(key-duplicates)


[error] 7-7: duplication of key "val_labels_path" in mapping

(key-duplicates)


[error] 27-27: duplication of key "use_augmentations_train" in mapping

(key-duplicates)

tests/assets/minimal_instance_bottomup/initial_config.yaml

[error] 6-6: duplication of key "train_labels_path" in mapping

(key-duplicates)


[error] 7-7: duplication of key "val_labels_path" in mapping

(key-duplicates)


[error] 21-21: duplication of key "use_augmentations_train" in mapping

(key-duplicates)


[error] 22-22: duplication of key "augmentation_config" in mapping

(key-duplicates)

tests/assets/minimal_instance_centroid/initial_config.yaml

[error] 6-6: duplication of key "train_labels_path" in mapping

(key-duplicates)


[error] 7-7: duplication of key "val_labels_path" in mapping

(key-duplicates)


[error] 25-25: duplication of key "use_augmentations_train" in mapping

(key-duplicates)


[error] 26-26: duplication of key "augmentation_config" in mapping

(key-duplicates)

tests/assets/minimal_instance/training_config.yaml

[error] 6-6: duplication of key "train_labels_path" in mapping

(key-duplicates)


[error] 7-7: duplication of key "val_labels_path" in mapping

(key-duplicates)


[error] 27-27: duplication of key "use_augmentations_train" in mapping

(key-duplicates)

tests/assets/minimal_instance_centroid/training_config.yaml

[error] 6-6: duplication of key "train_labels_path" in mapping

(key-duplicates)


[error] 7-7: duplication of key "val_labels_path" in mapping

(key-duplicates)


[error] 8-8: duplication of key "preprocessing" in mapping

(key-duplicates)


[error] 25-25: duplication of key "use_augmentations_train" in mapping

(key-duplicates)

tests/assets/minimal_instance_bottomup/training_config.yaml

[error] 6-6: duplication of key "train_labels_path" in mapping

(key-duplicates)


[error] 7-7: duplication of key "val_labels_path" in mapping

(key-duplicates)


[error] 8-8: duplication of key "preprocessing" in mapping

(key-duplicates)


[error] 21-21: duplication of key "use_augmentations_train" in mapping

(key-duplicates)


[error] 61-61: duplication of key "single_instance" in mapping

(key-duplicates)


[error] 62-62: duplication of key "centered_instance" in mapping

(key-duplicates)


[error] 63-63: duplication of key "centroid" in mapping

(key-duplicates)

Additional comments not posted (10)
tests/assets/minimal_instance/initial_config.yaml (1)

43-49: Review changes in model_config.

The changes in filters_rate, max_stride, and up_interpolate may affect model performance. Ensure these changes align with your intended model architecture and performance goals.

tests/assets/minimal_instance_bottomup/initial_config.yaml (2)

37-43: Review changes in model_config.

The changes in filters_rate, max_stride, and up_interpolate may affect model performance. Ensure these changes align with your intended model architecture and performance goals.


73-74: Review changes in trainer_config.

The changes in steps_per_epoch and max_epochs may affect the training schedule. Ensure these changes align with your training strategy.

tests/assets/minimal_instance_centroid/initial_config.yaml (1)

45-51: Review changes in model_config.

The changes in filters_rate, max_stride, and up_interpolate may affect model performance. Ensure these changes align with your intended model architecture and performance goals.

tests/assets/minimal_instance/training_config.yaml (1)

54-60: Review changes in model_config.

The changes in filters_rate, max_stride, and up_interpolate may affect model performance. Ensure these changes align with your intended model architecture and performance goals.

tests/assets/minimal_instance_centroid/training_config.yaml (1)

56-62: Review changes in model_config.

The changes in filters_rate, max_stride, and up_interpolate may affect model performance. Ensure these changes align with your intended model architecture and performance goals.

tests/assets/minimal_instance_bottomup/training_config.yaml (2)

93-94: Verify changes to training parameters.

The steps_per_epoch and max_epochs parameters have been modified. Ensure these changes align with the intended training strategy and objectives.


48-54: Verify changes to model architecture parameters.

The filters_rate, max_stride, and up_interpolate parameters have been modified. Ensure these changes align with the intended model architecture and performance goals.

tests/inference/test_single_instance.py (2)

17-19: Update function to load configurations directly.

The function now loads configurations directly from YAML files. This approach simplifies configuration management but ensure that the paths are correct and accessible.


54-57: Verify integration of new pipeline components.

The Resizer and PadToStride components have been added to the data pipeline. Ensure these components are correctly integrated and achieve the desired preprocessing effects.

Verification successful

Integration of Resizer and PadToStride Verified

The Resizer and PadToStride components are well-integrated into the data pipeline and their functionality is verified through existing tests.

  • Defined in sleap_nn/data/resizing.py.
  • Used in data pipelines (sleap_nn/data/pipelines.py) and inference models (sleap_nn/inference/predictors.py).
  • Tested in tests/data/test_resizing.py and other test files.

These components are correctly integrated and achieve the desired preprocessing effects.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `Resizer` and `PadToStride` in the data pipeline.

# Test: Search for the usage of `Resizer` and `PadToStride` in the codebase.
# Expect: Ensure that these components are correctly integrated and used.

rg --type python 'Resizer|PadToStride'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify the integration of `Resizer` and `PadToStride` in the data pipeline.

# Corrected Test: Search for the usage of `Resizer` and `PadToStride` in the codebase.
# Expect: Ensure that these components are correctly integrated and used.

rg 'Resizer|PadToStride' --glob '*.py' -A 5

Length of output: 12664

tests/assets/minimal_instance/initial_config.yaml Outdated Show resolved Hide resolved
tests/assets/minimal_instance/initial_config.yaml Outdated Show resolved Hide resolved
tests/assets/minimal_instance/initial_config.yaml Outdated Show resolved Hide resolved
tests/assets/minimal_instance_bottomup/initial_config.yaml Outdated Show resolved Hide resolved
tests/assets/minimal_instance_bottomup/initial_config.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ea9dfde and 8704e22.

Files selected for processing (7)
  • sleap_nn/inference/utils.py (2 hunks)
  • tests/assets/minimal_instance/initial_config.yaml (1 hunks)
  • tests/assets/minimal_instance/training_config.yaml (1 hunks)
  • tests/assets/minimal_instance_bottomup/initial_config.yaml (2 hunks)
  • tests/assets/minimal_instance_bottomup/training_config.yaml (2 hunks)
  • tests/assets/minimal_instance_centroid/initial_config.yaml (2 hunks)
  • tests/assets/minimal_instance_centroid/training_config.yaml (3 hunks)
Files skipped from review as they are similar to previous changes (3)
  • tests/assets/minimal_instance_bottomup/training_config.yaml
  • tests/assets/minimal_instance_centroid/initial_config.yaml
  • tests/assets/minimal_instance_centroid/training_config.yaml
Additional context used
yamllint
tests/assets/minimal_instance/training_config.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)

Additional comments not posted (22)
tests/assets/minimal_instance/initial_config.yaml (5)

29-29: Adjusting filters_rate to 1.5.

The filters_rate has been reduced from 2 to 1.5. This change might affect the model's feature extraction capacity by reducing the number of filters in the network layers. Ensure that this reduction aligns with the intended architecture and performance goals.


30-30: Reducing max_stride to 8.

The max_stride has been decreased from 16 to 8. This change will likely increase the spatial resolution during feature extraction, which can improve the model's ability to capture finer details. Verify that this change is consistent with the model's design requirements.


35-35: Changing up_interpolate to false.

The up_interpolate parameter has been switched from true to false. This change affects the model's upsampling strategy. Ensure that this modification aligns with the desired output resolution and quality.


38-38: Renaming bottomup to bottom_up.

The parameter bottomup has been renamed to bottom_up. This change improves clarity and consistency in naming conventions. Make sure that all references to this parameter in the codebase are updated accordingly.


43-43: Setting anchor_part to null.

The anchor_part value has been changed from 0 to null. This alteration may impact how the model interprets instance anchors. Verify that this change is intended and does not disrupt the model's functionality.

tests/assets/minimal_instance_bottomup/initial_config.yaml (5)

26-26: Adjusting filters_rate to 1.5.

The filters_rate has been reduced from 2 to 1.5. This change may impact the model's feature extraction capacity. Ensure that this adjustment aligns with the performance and architectural goals.


27-27: Reducing max_stride to 8.

The max_stride has been decreased from 16 to 8, potentially enhancing spatial resolution during feature extraction. Verify that this change is consistent with the model's design requirements.


32-32: Changing up_interpolate to false.

The up_interpolate parameter has been changed from true to false, affecting the model's upsampling strategy. Ensure this modification aligns with the desired output resolution.


62-62: Setting steps_per_epoch to 100.

The steps_per_epoch is now explicitly set to 100. This change suggests a more controlled training process. Verify that this setting is appropriate for the dataset and training objectives.


63-63: Reducing max_epochs to 10.

The max_epochs has been reduced from 50 to 10, indicating a shorter training duration. Ensure that this reduction is intentional and will not adversely affect the model's learning process.

tests/assets/minimal_instance/training_config.yaml (5)

40-40: Adjusting filters_rate to 1.5.

The filters_rate has been reduced from 2 to 1.5. This change might affect the model's feature extraction capacity. Ensure that this adjustment aligns with the performance and architectural goals.


41-41: Reducing max_stride to 8.

The max_stride has been decreased from 16 to 8, potentially enhancing spatial resolution during feature extraction. Verify that this change is consistent with the model's design requirements.


46-46: Changing up_interpolate to false.

The up_interpolate parameter has been switched from true to false, affecting the model's upsampling strategy. Ensure this modification aligns with the desired output resolution.


49-49: Renaming bottomup to bottom_up.

The parameter bottomup has been renamed to bottom_up. This change improves clarity and consistency in naming conventions. Make sure that all references to this parameter in the codebase are updated accordingly.


56-56: Setting anchor_part to null.

The anchor_part value has been changed from 0 to null. This alteration may impact how the model interprets instance anchors. Verify that this change is intended and does not disrupt the model's functionality.

sleap_nn/inference/utils.py (7)

56-71: Function interp1d added for linear interpolation.

The function interp1d has been added to perform linear 1-D interpolation using PyTorch tensors. Ensure that the usage of this function is well-documented and integrated into the codebase where necessary.


77-77: Ensure input validation for dimensions.

The assertion checks that inputs are at most 2-D. Ensure that this constraint is appropriate for all intended use cases.


85-94: Check dimension compatibility.

The function checks for dimension compatibility between x and y. Ensure that these checks are sufficient and consider edge cases that might arise.


96-102: Optimize handling of single-row inputs.

The code optimizes the handling of single-row inputs for x and y. Verify that this optimization is effective and does not introduce any unexpected behavior.


114-135: Review searchsorted and clamping logic.

The function uses torch.searchsorted and clamps indices. Ensure that this logic correctly handles edge cases and maintains the expected behavior of the interpolation.


136-153: Verify slope calculation and interpolation logic.

The slopes are calculated, and the interpolation is performed. Confirm that the computation is accurate and efficient for the expected input ranges.


154-157: Handle output shape for 1-D inputs.

The function adjusts the output shape for 1-D inputs. Ensure that this handling is correct and consistent with the expected output format.

@gitttt-1234 gitttt-1234 requested a review from talmo August 20, 2024 16:40
@talmo talmo changed the title Add minimal pretrained checkpoints for tests Add minimal pretrained checkpoints for tests and fix PAF grouping interpolation Sep 11, 2024
* Fix topdown aug

* Implement tracker module (#70)

* Refactor preprocessing config

* Merge train and val data configs

* Remove pipeline name

* Modify backbone_config

* Modify ckpts

* Fix inference tests

* Fix device for inference

* Fix scale in inference

* Fix Predictor

* Modify `bottom_up` to `bottomup`

* Fix bottomup inference

* Fix scale in augmentation

* Add tracker

* Fix tracker queue

* Add local queues

* Modify local queues\

* Add features

* Add optical flow

* Add Optical flow

* Add tracking score

* Refactor candidate update

* Integrate with Predictors

* Fix lint

* Fix tracks

* Resume training and automatically compute crop size for TopDownConfmaps pipeline (#79)

* Add option to automatically compute crop size

* Move find_crop_size to Trainer

* Fix skeleton name

* Add crop size to config

* Add resumable training option

* Add tests fore resuming training

* Fix tests

* Fix test for wandb folder

* LitData Refactor PR1: Get individual functions for data pipelines (#81)

* Add functions for data pipelines

* Add test cases

* Format file

* Add more test cases

* Fix augmentation test
Copy link
Contributor

@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: 12

Outside diff range and nitpick comments (2)
tests/assets/minimal_instance_bottomup/training_config.yaml (1)

83-83: LGTM, but provide more context on the usage.

The addition of resume_ckpt_path and prv_runid parameters is approved. As mentioned in the summary, they suggest enhancements in checkpoint management and tracking of previous runs, providing more flexibility in training workflows.

However, the parameters are left empty in the current changes. To improve clarity and maintainability, consider adding comments or documentation explaining their intended usage and how they should be populated. This will help future maintainers understand their purpose and ensure they are utilized correctly.

Also applies to: 90-90

sleap_nn/data/normalization.py (1)

44-48: Improve the apply_normalization function.

The apply_normalization function correctly normalizes the image tensor. However, consider the following improvements:

  1. Use torch.true_divide instead of the division operator for better performance and to avoid potential precision issues.
  2. Allow the user to specify the data type and the scaling factor to make the function more generic and reusable.
  3. Add type hints and docstrings to make the function more readable and maintainable.

Apply this diff to implement the suggested improvements:

-def apply_normalization(image: torch.Tensor):
-    """Normalize image tensor."""
-    if not torch.is_floating_point(image):
-        image = image.to(torch.float32) / 255.0
-    return image
+def apply_normalization(
+    image: torch.Tensor,
+    dtype: torch.dtype = torch.float32,
+    scale: float = 255.0,
+) -> torch.Tensor:
+    """Normalize image tensor.
+
+    Args:
+        image: The input image tensor.
+        dtype: The desired data type of the output tensor.
+        scale: The scaling factor to divide the pixel values by.
+
+    Returns:
+        The normalized image tensor.
+    """
+    if not torch.is_floating_point(image):
+        image = torch.true_divide(image.to(dtype), scale)
+    return image
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8704e22 and 9d65cc7.

Files selected for processing (44)
  • docs/config.md (2 hunks)
  • docs/config_bottomup.yaml (1 hunks)
  • docs/config_centroid.yaml (1 hunks)
  • docs/config_topdown_centered_instance.yaml (1 hunks)
  • sleap_nn/data/augmentation.py (2 hunks)
  • sleap_nn/data/confidence_maps.py (1 hunks)
  • sleap_nn/data/edge_maps.py (1 hunks)
  • sleap_nn/data/instance_centroids.py (3 hunks)
  • sleap_nn/data/instance_cropping.py (2 hunks)
  • sleap_nn/data/normalization.py (1 hunks)
  • sleap_nn/data/pipelines.py (4 hunks)
  • sleap_nn/data/providers.py (2 hunks)
  • sleap_nn/data/resizing.py (4 hunks)
  • sleap_nn/evaluation.py (1 hunks)
  • sleap_nn/inference/predictors.py (39 hunks)
  • sleap_nn/inference/topdown.py (3 hunks)
  • sleap_nn/tracking/init.py (1 hunks)
  • sleap_nn/tracking/candidates/fixed_window.py (1 hunks)
  • sleap_nn/tracking/candidates/local_queues.py (1 hunks)
  • sleap_nn/tracking/track_instance.py (1 hunks)
  • sleap_nn/tracking/tracker.py (1 hunks)
  • sleap_nn/tracking/utils.py (1 hunks)
  • sleap_nn/training/model_trainer.py (6 hunks)
  • tests/assets/minimal_instance/initial_config.yaml (2 hunks)
  • tests/assets/minimal_instance/training_config.yaml (1 hunks)
  • tests/assets/minimal_instance_bottomup/initial_config.yaml (2 hunks)
  • tests/assets/minimal_instance_bottomup/training_config.yaml (2 hunks)
  • tests/assets/minimal_instance_centroid/initial_config.yaml (3 hunks)
  • tests/assets/minimal_instance_centroid/training_config.yaml (3 hunks)
  • tests/data/test_augmentation.py (2 hunks)
  • tests/data/test_confmaps.py (2 hunks)
  • tests/data/test_edge_maps.py (2 hunks)
  • tests/data/test_instance_centroids.py (3 hunks)
  • tests/data/test_instance_cropping.py (2 hunks)
  • tests/data/test_normalization.py (2 hunks)
  • tests/data/test_pipelines.py (6 hunks)
  • tests/data/test_providers.py (2 hunks)
  • tests/data/test_resizing.py (2 hunks)
  • tests/fixtures/datasets.py (1 hunks)
  • tests/inference/test_predictors.py (5 hunks)
  • tests/tracking/candidates/test_fixed_window.py (1 hunks)
  • tests/tracking/candidates/test_local_queues.py (1 hunks)
  • tests/tracking/test_tracker.py (1 hunks)
  • tests/training/test_model_trainer.py (5 hunks)
Files skipped from review due to trivial changes (2)
  • sleap_nn/inference/topdown.py
  • sleap_nn/tracking/init.py
Additional context used
Ruff
tests/tracking/candidates/test_fixed_window.py

1-1: typing.DefaultDict imported but unused

Remove unused import

(F401)


1-1: typing.List imported but unused

Remove unused import

(F401)


2-2: numpy imported but unused

Remove unused import: numpy

(F401)


4-4: sleap_nn.tracking.track_instance.TrackedInstanceFeature imported but unused

Remove unused import: sleap_nn.tracking.track_instance.TrackedInstanceFeature

(F401)

tests/tracking/candidates/test_local_queues.py

2-2: numpy imported but unused

Remove unused import: numpy

(F401)

tests/data/test_instance_cropping.py

12-12: sleap_nn.data.resizing.PadToStride imported but unused

Remove unused import: sleap_nn.data.resizing.PadToStride

(F401)

sleap_nn/tracking/candidates/fixed_window.py

80-83: Use ternary operator new_track_id = 0 if not self.current_tracks else max(self.current_tracks) + 1 instead of if-else-block

Replace if-else-block with new_track_id = 0 if not self.current_tracks else max(self.current_tracks) + 1

(SIM108)

sleap_nn/data/providers.py

52-53: Use a single if statement instead of nested if statements

(SIM102)

tests/tracking/test_tracker.py

7-7: sleap_nn.tracking.track_instance.TrackInstanceLocalQueue imported but unused

Remove unused import: sleap_nn.tracking.track_instance.TrackInstanceLocalQueue

(F401)

sleap_nn/data/pipelines.py

7-7: typing.Optional imported but unused

Remove unused import: typing.Optional

(F401)

sleap_nn/data/edge_maps.py

255-257: Do not perform function call attrs.field in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


256-256: Do not perform function call attrs.converters.optional in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

sleap_nn/data/augmentation.py

210-210: f-string without any placeholders

Remove extraneous f prefix

(F541)

sleap_nn/tracking/tracker.py

515-515: Loop control variable idx not used within loop body

(B007)

sleap_nn/training/model_trainer.py

311-311: Ambiguous variable name: l

(E741)

yamllint
tests/assets/minimal_instance/training_config.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)

Markdownlint
docs/config.md

29-29: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


30-30: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


160-160: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


161-161: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


162-162: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


163-163: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


164-164: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


165-165: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


166-166: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)

Additional comments not posted (147)
tests/data/test_normalization.py (2)

4-8: LGTM!

The import statement has been correctly updated to include the new apply_normalization function from the sleap_nn.data.normalization module.


37-42: LGTM!

The new test function test_apply_normalization is well-implemented and covers the essential aspects of the apply_normalization function. It correctly checks that:

  • The maximum value of the normalized image does not exceed 1.0.
  • The minimum value of the normalized image is 0.0.
  • The data type of the normalized image is torch.float32.

This test function will help ensure the correctness of the apply_normalization function and improve the overall test coverage of the codebase.

sleap_nn/tracking/track_instance.py (3)

9-19: LGTM!

The TrackInstances class is well-defined and follows best practices:

  • It uses type annotations for all attributes.
  • It has a docstring describing the purpose of the class.
  • It uses the attrs library to reduce boilerplate code.
  • It is cohesive and has a single responsibility.

The code changes are approved.


22-33: LGTM!

The TrackInstanceLocalQueue class is well-defined and follows best practices:

  • It uses type annotations for all attributes.
  • It has a docstring describing the purpose of the class.
  • It uses the attrs library to reduce boilerplate code.
  • It is cohesive and has a single responsibility.

The code changes are approved.


36-50: LGTM!

The TrackedInstanceFeature class is well-defined and follows best practices:

  • It uses type annotations for all attributes.
  • It has a detailed docstring describing the purpose of the class and the shifted_keypoints attribute.
  • It uses the attrs library to reduce boilerplate code.
  • It is cohesive and has a single responsibility.

The code changes are approved.

tests/assets/minimal_instance_centroid/initial_config.yaml (6)

26-26: LGTM!

The change to the filters_rate parameter is approved. It reduces the model complexity as mentioned in the summary.


27-27: LGTM!

The change to the max_stride parameter is approved. It reduces the maximum stride as mentioned in the summary, which may impact the feature map resolution.


32-32: LGTM!

The change to the up_interpolate parameter is approved. It modifies the upsampling behavior as mentioned in the summary.


62-62: LGTM!

The addition of the resume_ckpt_path parameter to trainer_config is approved. It enhances the configurability of the training process by allowing the resumption of training from a specific checkpoint, as mentioned in the summary.


69-69: LGTM!

The addition of the prv_runid parameter to trainer_config.wandb is approved. It enhances the tracking of previous runs in the Weights and Biases integration, as mentioned in the summary.


39-39: LGTM, but verify the impact.

The change to the anchor_part parameter is approved.

However, please ensure that setting anchor_part to null does not introduce any unintended consequences or errors in the codebase. Verify that the model training and inference processes handle this null value correctly. Run the following script to search for potential issues:

tests/assets/minimal_instance/initial_config.yaml (5)

29-29: LGTM!

The change to filters_rate is approved.


30-30: LGTM!

The change to max_stride is approved.


35-35: LGTM!

The change to up_interpolate is approved.


66-66: LGTM!

The addition of resume_ckpt_path and prv_runid keys is approved.

Also applies to: 73-73


43-43: LGTM, but verify the null value handling.

The change to anchor_part is approved.

However, ensure that the code handles the null value correctly to avoid potential issues.

Run the following script to verify the null value handling:

tests/assets/minimal_instance_bottomup/initial_config.yaml (6)

26-26: LGTM!

The change to filters_rate is approved.


27-27: LGTM!

The change to max_stride is approved.


32-32: LGTM!

The change to up_interpolate is approved.


62-63: LGTM!

The changes to steps_per_epoch and max_epochs are approved.


68-68: LGTM!

The addition of resume_ckpt_path is approved.


75-75: LGTM!

The addition of prv_runid is approved.

tests/assets/minimal_instance_centroid/training_config.yaml (6)

37-37: Verify the impact of reducing filters_rate.

Reducing the filters_rate from 2 to 1.5 may decrease the model complexity and affect its learning capacity.

Ensure this change is thoroughly tested to confirm the model still performs as expected with the reduced filters_rate.


38-38: Verify the impact of reducing max_stride.

Reducing the max_stride from 16 to 8 may lead to a finer resolution in feature extraction during the convolutional operations.

Ensure this change is thoroughly tested to confirm the model still performs as expected with the reduced max_stride.


43-43: Verify the impact of disabling up_interpolate.

Changing up_interpolate from true to false may impact the model's ability to reconstruct features at higher resolutions.

Ensure this change is thoroughly tested to confirm the model still performs as expected with up_interpolate disabled.


47-47: Verify the references to the renamed bottom_up key.

The bottomup key has been renamed to bottom_up. This is a minor change, but it may affect how configurations are referenced in the codebase.

Ensure all references to this key have been updated accordingly.


50-50: Verify the impact of changing anchor_part to null.

Changing the anchor_part parameter from a fixed value of 0 to null may affect how anchor points are defined or utilized in the model's output processing.

Ensure this change is thoroughly tested to confirm the model still performs as expected with anchor_part set to null.


73-73: LGTM!

The addition of resume_ckpt_path and prv_runid parameters enhances the checkpoint management capabilities during training, allowing for more flexible model training and evaluation processes.

Also applies to: 80-80

tests/tracking/candidates/test_fixed_window.py (2)

9-24: LGTM!

The code changes are approved.


27-52: LGTM!

The code changes are approved.

tests/assets/minimal_instance_bottomup/training_config.yaml (5)

37-37: LGTM!

The change to filters_rate is approved. It may impact the model's feature learning capacity as mentioned in the summary.


38-38: LGTM!

The change to max_stride is approved. As mentioned in the summary, it may affect the model's output resolution and ability to capture fine details.


43-43: LGTM!

The change to up_interpolate is approved. As mentioned in the summary, it alters the upsampling behavior in the model.


77-77: LGTM!

The change to steps_per_epoch is approved. As mentioned in the summary, it enhances control over the training duration.


78-78: LGTM, but verify the impact on model performance.

The change to max_epochs is approved. As mentioned in the summary, it indicates a shorter training period which may affect model performance and convergence.

Ensure that the reduced number of epochs does not negatively impact the model's performance. Monitor the validation metrics during training to assess if the model converges well within the specified epochs. If needed, consider increasing the max_epochs to allow for better convergence.

tests/tracking/candidates/test_local_queues.py (2)

9-24: LGTM!

The code changes are approved.


27-55: LGTM!

The code changes are approved.

docs/config_bottomup.yaml (1)

99-99: LGTM!

The addition of resume_ckpt_path is a valid configuration option that enhances the flexibility of the training process by allowing users to resume training from a checkpoint.

docs/config_topdown_centered_instance.yaml (1)

97-97: LGTM!

The addition of resume_ckpt_path in the trainer_config section is approved. This is a useful configuration option that allows users to resume training from a checkpoint, providing flexibility in managing training sessions.

tests/data/test_instance_centroids.py (2)

10-35: LGTM!

The test function test_generate_centroids is well-implemented and covers the important scenarios:

  1. Testing with complete instance data.
  2. Testing with partial instance data.

The code changes are approved.


Line range hint 37-72: LGTM!

The test function test_instance_centroids is well-implemented and covers the important scenarios:

  1. Testing InstanceCentroidFinder with an undefined anchor index.
  2. Testing generate_centroids with a defined anchor index.
  3. Testing generate_centroids with a defined anchor index and partial instance data.

The code changes are approved.

tests/assets/minimal_instance/training_config.yaml (6)

40-40: LGTM!

The change to filters_rate is approved.


41-41: LGTM!

The change to max_stride is approved.


46-46: LGTM!

The change to up_interpolate is approved.


56-56: LGTM!

The change to anchor_part is approved.


79-79: LGTM!

The addition of resume_ckpt_path is approved.


86-86: LGTM!

The addition of prv_runid is approved.

tests/data/test_providers.py (1)

96-103: LGTM!

The new test function test_process_lf is a valuable addition that enhances the test coverage for the process_lf function. It correctly verifies the expected output shapes and the presence of NaN values in the "instances" tensor under certain conditions.

The code changes are approved.

docs/config_centroid.yaml (2)

116-116: LGTM!

The addition of the resume_ckpt_path key under trainer_config is a useful enhancement for checkpoint management.


122-122: LGTM, but verify the key's purpose.

The addition of the prv_runid key under wandb is a useful enhancement for experiment tracking.

However, please verify that the key is indeed intended to track the previous run ID for better management of experiments.

sleap_nn/data/instance_centroids.py (2)

Line range hint 38-63: LGTM!

The renaming of the function from find_centroids to generate_centroids improves the semantic clarity of its purpose. The accompanying updates to the documentation, specifically changing n_points to n_nodes and clarifying the output tensor shape, provide clearer expectations for users regarding the input and output data structures.

The function logic remains unchanged, maintaining the overall behavior while enhancing the readability and understandability of the code.


91-93: LGTM!

The InstanceCentroidFinder class has been updated to use the renamed generate_centroids function in the __iter__ method. This change maintains consistency with the updated function name and ensures that the new function is correctly used when assigning centroids to the examples processed by the class.

The update reflects the improved semantic clarity of the centroid generation process without altering the fundamental logic or control flow of the class.

tests/data/test_instance_cropping.py (2)

16-26: LGTM!

The new test function test_find_instance_crop_size is well-structured and covers the important cases. The code changes are approved.


89-103: LGTM!

The new test function test_generate_crops is correctly implemented and validates the important aspects of the generate_crops function. The code changes are approved.

sleap_nn/tracking/utils.py (8)

10-13: LGTM!

The code changes are approved.


16-35: LGTM!

The code changes are approved.


38-42: LGTM!

The code changes are approved.


45-51: LGTM!

The code changes are approved.


54-67: LGTM!

The code changes are approved.


70-72: LGTM!

The code changes are approved.


75-92: LGTM!

The code changes are approved.


95-100: LGTM!

The code changes are approved.

tests/data/test_augmentation.py (2)

44-64: LGTM!

The test_apply_intensity_augmentation function is a well-structured test that covers the essential aspects of the apply_intensity_augmentation function. It validates the output types, shapes, and the effect of the augmentations on the input image. The assertions ensure the correctness of the function's behavior.

The code changes are approved.


67-97: LGTM!

The test_apply_geometric_augmentation function thoroughly tests the apply_geometric_augmentation function. It validates the output types, shapes, and the effect of the augmentations on the input image. The assertions ensure the correctness of the function's behavior.

Additionally, the test case for invalid cropping parameters is a good addition, as it checks the function's robustness against incorrect inputs.

The code changes are approved.

tests/data/test_resizing.py (3)

85-93: LGTM!

The code changes are approved.


96-106: LGTM!

The code changes are approved.


109-131: LGTM!

The code changes are approved.

tests/data/test_confmaps.py (3)

128-137: LGTM!

The new test function test_generate_confmaps looks good. It provides solid test coverage for the generate_confmaps function by:

  1. Loading and processing a minimal instance
  2. Calling generate_confmaps with the processed instance data
  3. Asserting that the generated confidence maps have the expected shape

The code changes are approved.


140-157: LGTM!

The new test function test_generate_multiconfmaps looks good. It provides solid test coverage for the generate_multiconfmaps function by:

  1. Loading and processing a minimal instance
  2. Calling generate_multiconfmaps with the processed instance data
  3. Asserting that the generated confidence maps have the expected shape
  4. Testing both the standard output and an output variant that uses centroids

The code changes are approved.


2-15: LGTM!

The new import statements look good:

  • sleap_io imported as sio is used to load the minimal instance in the test functions.
  • generate_confmaps and generate_multiconfmaps imported from sleap_nn.data.confidence_maps are the functions being tested.
  • process_lf imported from sleap_nn.data.providers is used to process the loaded instance data.

The code changes are approved.

tests/fixtures/datasets.py (2)

133-133: LGTM!

The addition of the resume_ckpt_path parameter with a default value of None is a useful enhancement to support resuming training from a checkpoint.


140-140: LGTM!

The addition of the prv_runid parameter with a default value of None is a useful enhancement to support tracking previous run identifiers when using Weights & Biases for experiment tracking.

tests/data/test_edge_maps.py (1)

178-189: LGTM!

The new test function test_generate_pafs is a valuable addition to the test suite. It correctly validates the functionality of the generate_pafs method by:

  1. Loading label data using sleap_io.
  2. Processing the loaded labels with process_lf.
  3. Calling generate_pafs with the processed instances and specific image dimensions.
  4. Asserting that the output shape of the generated PAFs matches the expected dimensions.

This enhances the test coverage for the edge map generation functionality, ensuring that the generate_pafs method behaves as intended.

sleap_nn/tracking/candidates/fixed_window.py (5)

25-30: LGTM!

The code changes are approved.


32-49: LGTM!

The code changes are approved.


51-76: LGTM!

The code changes are approved.


86-105: LGTM!

The code changes are approved.


107-143: LGTM!

The code changes are approved.

sleap_nn/tracking/candidates/local_queues.py (7)

13-28: Class is well-documented and has a clear purpose.

The LocalQueueCandidates class is well-documented with a clear description of its purpose and attributes. The class handles track assignments using the local queues method, where track assignments are determined based on the last window_size instances for each track.


30-41: LGTM!

The __init__ method correctly initializes all the class variables based on the provided arguments or default values.


43-63: LGTM!

The get_track_instances method correctly creates TrackInstanceLocalQueue instances for each untracked instance and returns them as a list.


65-88: LGTM!

The get_features_from_track_id method correctly retrieves the instances from the tracker queue based on the provided track_id and creates TrackedInstanceFeature objects for each instance.


101-115: LGTM!

The add_new_tracks method correctly adds new track IDs to the TrackInstanceLocalQueue objects and to the tracker queue based on the instance score threshold.


117-151: LGTM!

The update_tracks method correctly updates the TrackInstanceLocalQueue objects with the assigned track IDs and tracking scores based on the output of the track matching algorithm. It also adds new tracks for instances with unassigned tracks.


153-164: LGTM!

The get_instances_groupby_frame_idx method correctly groups the TrackInstanceLocalQueue objects by frame index and returns them as a dictionary.

sleap_nn/data/instance_cropping.py (3)

12-60: LGTM!

The new find_instance_crop_size function is well-documented and the logic is correct. It correctly computes the size of the largest instance bounding box from labels, taking into account padding, maximum stride, input scaling, and a minimum crop size. The function ensures that the computed crop size is divisible by the maximum stride and is larger than or equal to the minimum crop size.


109-154: LGTM!

The new generate_crops function is well-documented and the logic is correct. It correctly generates cropped images for a given centroid and adjusts the keypoints and centroids to the crop. The function takes an input image, instance keypoints, centroid, and crop size as input and returns a dictionary with cropped images, bounding box for the cropped instance, keypoints and centroids adjusted to the crop.


164-164: LGTM!

The change to the docstring for the crop_hw attribute improves the clarity by specifying that it represents the height and width of the crop in pixels.

sleap_nn/data/providers.py (1)

31-91: LGTM!

The process_lf function is well-structured and handles various aspects of processing a labeled frame effectively. It filters user instances, transposes image data, collects non-empty instances, pads instances to match the maximum number of instances, converts data to PyTorch tensors, and returns a dictionary containing the processed data.

The code changes are approved.

Tools
Ruff

52-53: Use a single if statement instead of nested if statements

(SIM102)

sleap_nn/data/resizing.py (3)

Line range hint 36-67: LGTM!

The changes to the apply_pad_to_stride function are approved:

  • The function renaming follows a more descriptive naming convention, improving code readability.
  • The conditional check prevents unnecessary computations when the stride is 1 or less, enhancing the function's robustness.
  • The function correctly applies padding to the bottom and right of the image to ensure divisibility by max_stride.

88-103: LGTM!

The addition of the apply_resizer function is approved:

  • The function correctly resizes both the image and keypoints based on the specified scale factor.
  • The check to avoid resizing when the scale is 1.0 optimizes performance by avoiding redundant operations.
  • The function returns a tuple of the resized image and keypoints, which is a clear and expected output.

106-134: LGTM!

The addition of the apply_sizematcher function is approved:

  • The function correctly pads the image to the specified maximum dimensions.
  • The validation ensures that the maximum dimensions are valid and prevents potential issues with negative padding.
  • Raising appropriate errors helps with error handling and provides clear feedback to the user.
  • The function returns the padded image, which is a clear and expected output.
sleap_nn/data/confidence_maps.py (2)

11-46: LGTM!

The generate_confmaps function is well-structured and documented. It handles different input shapes correctly and generates confidence maps using the make_confmaps function.


49-94: LGTM!

The generate_multiconfmaps function is well-structured and documented. It extends the functionality of generate_confmaps to handle multiple instances and provides flexibility in generating confidence maps for either full instances or centroids.

tests/tracking/test_tracker.py (2)

13-29: LGTM!

The code changes are approved.


32-219: LGTM!

The code changes are approved. The test function test_tracker is comprehensive and well-structured. It covers various configurations and methods of the Tracker class.

tests/inference/test_predictors.py (4)

159-177: LGTM!

The new test case for the tracking functionality looks good. It correctly verifies that:

  • The number of tracks produced does not exceed the specified maximum.
  • Each instance within the predicted labels has a valid track and a tracking score of 1.

339-339: LGTM!

The assertion has been correctly updated to ensure that the length of instances is less than or equal to the expected maximum, enhancing the flexibility of the test.


393-393: LGTM!

The assertion has been correctly updated to ensure that the length of instances is less than or equal to the expected maximum, enhancing the flexibility of the test.


428-444: LGTM!

The new test case for the tracking functionality looks good. It correctly verifies that:

  • Each instance within the predicted labels has a valid track and a tracking score of 1.
  • The number of tracks produced does not exceed the specified maximum.
sleap_nn/data/pipelines.py (4)

33-51: LGTM!

The changes to the TopdownConfmapsPipeline class enhance configurability and maintainability:

  • The new crop_hw parameter allows specifying the crop height and width during initialization.
  • The refactored augmentation logic improves readability by nesting the checks for intensity and geometric augmentations within a single conditional block.

The code changes are approved.

Also applies to: 76-90, 96-96


Line range hint 130-230: Skipped review.

No changes were made to the SingleInstanceConfmapsPipeline class.

Tools
Ruff

7-7: typing.Optional imported but unused

Remove unused import: typing.Optional

(F401)


Line range hint 233-323: Skipped review.

No changes were made to the CentroidConfmapsPipeline class.

Tools
Ruff

7-7: typing.Optional imported but unused

Remove unused import: typing.Optional

(F401)


Line range hint 326-426: Skipped review.

No changes were made to the BottomUpPipeline class.

Tools
Ruff

7-7: typing.Optional imported but unused

Remove unused import: typing.Optional

(F401)

sleap_nn/data/edge_maps.py (2)

250-323: LGTM!

The new generate_pafs function looks good:

  • It is well-documented with a clear description of the arguments and return values.
  • The logic is broken down into smaller steps with assertions to validate the intermediate results.
  • The output shape is clearly defined and matches the description.

Great job on adding this new functionality!

Tools
Ruff

255-257: Do not perform function call attrs.field in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


256-256: Do not perform function call attrs.converters.optional in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


255-257: The Ruff hints for B008 are false positives. The attrs.field and attrs.converters.optional calls are used correctly here to define the type and default value of the edge_inds argument. Moving these calls outside the function would change the behavior and make the code less readable. The attrs library is designed to be used this way.

Tools
Ruff

255-257: Do not perform function call attrs.field in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


256-256: Do not perform function call attrs.converters.optional in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

tests/training/test_model_trainer.py (4)

44-54: LGTM!

The added test case for creating data loaders without explicitly providing crop_hw looks good. It correctly verifies that the data loaders are created with the expected number of samples and the instance image has the correct shape based on the min_crop_size configuration.


118-119: LGTM!

The changes to update the configuration to not explicitly provide crop_hw and set min_crop_size instead are consistent with the changes in the test_create_data_loader function and look good.


187-212: LGTM!

The new test case for resuming training from a checkpoint looks good. It correctly verifies that the training state, including the epoch number and wandb run ID, is restored as expected when resuming from a checkpoint.


217-217: Verify the impact of early stopping configuration changes.

The min_delta parameter in the early stopping configuration is changed from 1e-3 to 1e-1, and a new patience parameter is added. These changes may affect the sensitivity of the early stopping mechanism.

Please ensure that the updated values are appropriate for your use case and verify that the early stopping behaves as expected with these new settings.

Also applies to: 219-219

docs/config.md (4)

29-29: LGTM!

The change from a list to a tuple for the crop_hw parameter is approved. This enforces a stricter and more predictable type requirement.

Tools
Markdownlint

29-29: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


30-30: LGTM!

The addition of the min_crop_size parameter is approved. It provides more control over the cropping behavior when crop_hw is set to None.

Tools
Markdownlint

30-30: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)


160-160: LGTM!

The addition of the resume_ckpt_path parameter is approved. It enhances the functionality for resuming training from a specific checkpoint file.

Tools
Markdownlint

160-160: Expected: 2; Actual: 4
Unordered list indentation

(MD007, ul-indent)


166-166: LGTM!

The addition of the prv_runid parameter under the wandb section is approved. It improves the tracking and resuming of training runs by associating the current run with a previous run ID.

Tools
Markdownlint

166-166: Expected: 4; Actual: 8
Unordered list indentation

(MD007, ul-indent)

sleap_nn/evaluation.py (1)

222-222: LGTM!

The change from using float64 to float32 for computing n_visible_gt is a reasonable optimization. Using float32 can provide memory savings and potentially improve performance on certain hardware, with minimal impact on precision for this particular computation.

The rest of the OKS computation remains unchanged, so this modification is unlikely to affect the correctness of the results.

sleap_nn/data/augmentation.py (4)

13-106: LGTM!

The apply_intensity_augmentation function is well-implemented and follows best practices. The code is clean, well-documented, and easy to understand.


109-231: LGTM!

The apply_geometric_augmentation function is well-implemented and follows best practices. The code is clean, well-documented, and easy to understand.

Tools
Ruff

210-210: f-string without any placeholders

Remove extraneous f prefix

(F541)


Line range hint 233-298: LGTM!

The RandomUniformNoise class is a well-implemented custom Kornia augmentation. It follows the Kornia augmentation pattern and has a clear docstring explaining its usage.

Tools
Ruff

210-210: f-string without any placeholders

Remove extraneous f prefix

(F541)


Line range hint 300-514: LGTM!

The KorniaAugmenter class is a well-implemented IterDataPipe that applies various augmentations to images and instances using Kornia. The code is clean, well-documented, and easy to understand.

tests/data/test_pipelines.py (1)

95-95: LGTM!

The changes to the test_topdownconfmapspipeline function are approved.

Defining the crop_hw variable at the beginning of the function and passing it to the TopdownConfmapsPipeline constructor in multiple instances enhances the configurability of the pipeline. This allows different cropping dimensions to be specified directly in the test cases, improving the flexibility of the test setup.

Also applies to: 111-114, 189-192, 269-272

sleap_nn/tracking/tracker.py (13)

84-178: LGTM!

The code changes are approved.


180-246: LGTM!

The code changes are approved.


248-282: LGTM!

The code changes are approved.


284-286: LGTM!

The code changes are approved.


288-305: LGTM!

The code changes are approved.


307-359: LGTM!

The code changes are approved.


361-365: LGTM!

The code changes are approved.


367-401: LGTM!

The code changes are approved.


445-460: LGTM!

The code changes are approved.


462-484: LGTM!

The code changes are approved.


487-570: LGTM!

The code changes are approved.

Tools
Ruff

515-515: Loop control variable idx not used within loop body

(B007)


515-515: Skip the Ruff warning.

The Ruff warning is a false positive. The loop control variable idx is used to index into ref_candidate_list and shifted_pts within the loop body.

Tools
Ruff

515-515: Loop control variable idx not used within loop body

(B007)


572-604: LGTM!

The code changes are approved.

sleap_nn/training/model_trainer.py (6)

25-25: LGTM!

The code changes are approved.


93-123: LGTM!

The code changes for computing the crop size look good. Using the find_instance_crop_size function to derive an appropriate crop size based on the training labels and config settings is a nice addition.


298-325: Great job improving the training process!

The changes enhance the robustness and functionality of the training process:

  • The try-except-finally block ensures proper handling of exceptions during training.
  • The ckpt_path parameter allows resuming training from a checkpoint, which is a useful feature.
  • Saving the final config with the wandb run ID and total model parameters is excellent for tracking and reproducibility.
Tools
Ruff

311-311: Ambiguous variable name: l

(E741)


277-278: LGTM!

Using a default name "skeleton-0" when the skeleton name is not provided is a good fallback to ensure the config can be saved correctly.


Line range hint 1-1:

Tools
Ruff

27-27: torchvision.models.swin_transformer.Swin_T_Weights imported but unused

Remove unused import

(F401)


28-28: torchvision.models.swin_transformer.Swin_S_Weights imported but unused

Remove unused import

(F401)


311-311: Minor: Consider renaming variable l to a more descriptive name if it doesn't make the line too long. Okay to ignore for now given the narrow scope.

Ruff reports that the variable name l is ambiguous. While a more descriptive name would be better, renaming it might make the line too long. Since this is a minor issue in a very narrow scope (within a list comprehension), it can be ignored for now.

Tools
Ruff

311-311: Ambiguous variable name: l

(E741)

sleap_nn/inference/predictors.py (8)

21-21: LGTM!

The renaming of the function to apply_pad_to_stride reflects a clearer intent of the function's purpose.


54-54: LGTM!

The update to the preprocess attribute ensures that the image padding logic is consistently applied during preprocessing.


370-372: LGTM!

The addition of the tracker attribute allows for the association of detections over time, enabling tracking of predicted instances across frames.


376-390: LGTM!

The removal of the output_stride and pafs_output_stride parameters indicates a shift in how output strides are managed, as they are now derived from configuration objects rather than being passed directly as parameters. This change enhances the flexibility and configurability of the model's inference process.

Also applies to: 510-527


390-390: LGTM!

The addition of the tracker attribute allows for the association of detections over time, enabling tracking of predicted instances across frames.


Line range hint 749-1064:


1087-1087: LGTM!

The addition of the tracker attribute allows for the association of detections over time, enabling tracking of predicted instances across frames.


Line range hint 1391-1504: LGTM!

The addition of the tracking parameters to the main function allows users to enable tracking functionality directly from the main entry point of the application, providing greater control over the inference process.

tests/tracking/candidates/test_fixed_window.py Outdated Show resolved Hide resolved
tests/tracking/candidates/test_local_queues.py Outdated Show resolved Hide resolved
tests/data/test_instance_cropping.py Outdated Show resolved Hide resolved
sleap_nn/data/providers.py Outdated Show resolved Hide resolved
tests/tracking/test_tracker.py Outdated Show resolved Hide resolved
sleap_nn/data/pipelines.py Outdated Show resolved Hide resolved
docs/config.md Outdated Show resolved Hide resolved
sleap_nn/data/augmentation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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: 2

Outside diff range and nitpick comments (1)
tests/assets/minimal_instance/training_config.yaml (1)

56-56: Consider using an anchor part if applicable.

Setting anchor_part to null means the model will not use any specific part as an anchor for the centered instance head. While this makes sense if there is no natural choice for an anchor, using an anchor part can provide a stable reference point and make the predictions more robust.

If your skeleton topology has a part that can serve as a reliable anchor (e.g., the head or the root of the skeleton), consider specifying it as the anchor_part instead of using null.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9d65cc7 and f9462b3.

Files selected for processing (8)
  • sleap_nn/inference/predictors.py (1 hunks)
  • tests/assets/minimal_instance/initial_config.yaml (1 hunks)
  • tests/assets/minimal_instance/training_config.yaml (1 hunks)
  • tests/assets/minimal_instance_bottomup/initial_config.yaml (2 hunks)
  • tests/assets/minimal_instance_bottomup/training_config.yaml (2 hunks)
  • tests/assets/minimal_instance_centroid/initial_config.yaml (2 hunks)
  • tests/assets/minimal_instance_centroid/training_config.yaml (3 hunks)
  • tests/inference/test_predictors.py (3 hunks)
Files skipped from review as they are similar to previous changes (3)
  • tests/assets/minimal_instance_bottomup/initial_config.yaml
  • tests/assets/minimal_instance_centroid/initial_config.yaml
  • tests/inference/test_predictors.py
Additional context used
yamllint
tests/assets/minimal_instance/training_config.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)

Additional comments not posted (13)
tests/assets/minimal_instance/initial_config.yaml (3)

29-30: Monitor the impact of changes to filters_rate and max_stride.

Reducing filters_rate from 2 to 1.5 will decrease the number of filters in each subsequent layer, which may reduce the model's capacity and performance.

Reducing max_stride from 16 to 8 will increase the spatial resolution of the feature maps, which may improve the model's ability to capture fine-grained details but also increase computational cost.

Please monitor the model's performance metrics (e.g., accuracy, loss) and resource usage (e.g., memory, runtime) to ensure these changes are beneficial and do not introduce performance regressions or exceed resource constraints.


35-35: Verify the impact of disabling up_interpolate.

Setting up_interpolate to false suggests a change in how the model handles upsampling, potentially using transposed convolutions instead of interpolation.

This change may affect the output resolution, quality, or artifacts in the generated feature maps.

Please compare the output quality and artifacts with the previous setting (up_interpolate: true) to ensure this change is beneficial and does not introduce any undesired effects.


43-43: Verify the impact of setting anchor_part to null.

Changing anchor_part from 0 to null suggests a modification in how the model identifies or utilizes anchor points in its processing.

This change may affect the model's ability to localize or track specific parts or regions of interest.

Please verify the model's output and performance metrics (e.g., localization accuracy, tracking precision) to ensure this change is beneficial and does not introduce any undesired effects on the model's localization or tracking capabilities.

tests/assets/minimal_instance_centroid/training_config.yaml (5)

37-37: Reduced filters_rate may impact model complexity.

Decreasing the filters_rate from 2 to 1.5 will reduce the number of filters in each subsequent layer of the model. This change can:

  • Reduce the model's capacity to learn complex features.
  • Help prevent overfitting, especially on smaller datasets.

Monitor the model's performance to ensure it still learns effectively with this reduced complexity.


38-38: Reduced max_stride may improve spatial resolution.

Decreasing the max_stride from 16 to 8 will reduce the maximum stride of the convolutional layers in the model. This change can:

  • Allow the model to capture finer-grained spatial details.
  • Increase computational cost and memory usage.

Ensure that the computational resources are sufficient to handle this increased spatial resolution.


43-43: Switching to transposed convolution for upsampling.

Changing up_interpolate from true to false will use transposed convolution instead of interpolation for upsampling in the model. This change can:

  • Allow the model to learn to generate more detailed outputs.
  • Potentially introduce checkerboard artifacts in the output.

Monitor the model's output for any artifacts and consider using techniques like kernel size adjustment or output padding to mitigate them if necessary.


50-50: Clarify the implications of setting anchor_part to null.

Changing anchor_part from 0 to null suggests that the model will no longer use a fixed anchor part for the centroid prediction. This change raises the following questions:

  • How will the absence of a fixed anchor part affect the model's centroid predictions?
  • Will this change require modifications to the post-processing code that handles the model's output?

Please provide more context on the motivation behind this change and clarify how it will be handled in the codebase.


47-47: Renamed bottomup to bottom_up for clarity.

Renaming bottomup to bottom_up improves the readability of the configuration. However, this change requires updating all references to this parameter in the codebase to avoid breaking the code.

Please run the following command to find all references to bottomup in the codebase and ensure they are updated to bottom_up:

tests/assets/minimal_instance_bottomup/training_config.yaml (3)

37-37: Clarify the reason for reducing filters_rate.

The filters_rate parameter in model_config.backbone_config has been reduced from 2 to 1.5. This change may decrease the model's ability to learn complex features.

Please provide clarification on the motivation behind this reduction and how it aligns with the desired model performance.


38-38: Confirm the impact of reducing max_stride.

The max_stride parameter in model_config.backbone_config has been decreased from 16 to 8. This change may enhance the model's spatial resolution and detail capture.

Please confirm that this reduction aligns with the desired model behavior and performance expectations.


43-43: Clarify the reason for changing up_interpolate to false.

The up_interpolate parameter in model_config.backbone_config has been changed from true to false. This modification alters the upsampling behavior in the model architecture.

Please provide clarification on the motivation behind this change and the expected benefits it brings to the model's performance.

tests/assets/minimal_instance/training_config.yaml (2)

40-41: LGTM!

The changes to filters_rate and max_stride in the model_config are approved.

Reducing the filters_rate can help control model complexity and overfitting. Lowering the max_stride allows the model to preserve more spatial information, which is important for the centered instance head.


46-46: Verify the impact of using transposed convolutions for upsampling.

Setting up_interpolate to false means the model will use transposed convolutions instead of interpolation for upsampling in the decoder. While transposed convolutions can learn to upsample adaptively, they may introduce checkerboard artifacts.

Please verify that using transposed convolutions improves the model performance on your specific data and use case. If not, consider reverting to interpolation for simplicity.

@gitttt-1234 gitttt-1234 merged commit 4425b2b into main Sep 12, 2024
7 checks passed
@gitttt-1234 gitttt-1234 deleted the greg/minimalinstances branch September 12, 2024 17:55
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.

Minimal ckpts for test functions
4 participants