Skip to content

Conversation

@gitttt-1234
Copy link
Collaborator

@gitttt-1234 gitttt-1234 commented Nov 6, 2025

Summary

Extends centroid cropping with optional orientation-based rotation during inference, similar to the egocentric rotation already available in the training pipeline.

What's Different from Standard Centroid Cropping?

Standard centroid cropping extracts fixed-size crops around detected centroids without rotation. This branch adds optional egocentric rotation that aligns instances to a canonical orientation before cropping:

  • Images and keypoints are rotated to align orientation anchor points along the positive x-axis
  • Crops are extracted from the rotated images
  • Predictions are inverse-rotated back to the original orientation
  • Coordinates are correctly transformed from crop space to full image space

Usage Example

from omegaconf import OmegaConf
from sleap_nn.training.model_trainer import ModelTrainer

if __name__ == "__main__":

    config = OmegaConf.load("config.yaml")
    trainer = ModelTrainer.get_model_trainer_from_config(config, orientation_anchor_parts=["nose", "top of neck", "left ear", "right ear"])
    trainer.train()

Key Changes

  • Add orientation_anchor_parts parameter throughout inference pipeline
  • Apply per-instance egocentric rotation in CentroidCrop._generate_crops()
  • Store rotation angles and apply inverse rotation in FindInstancePeaks.forward()
  • Fix coordinate transformation from crop to full image space

🤖 Generated with Claude Code

Extends centroid cropping with optional orientation-based rotation during inference. Images and keypoints are rotated to align orientation anchor points along the positive x-axis before cropping, then predictions are inverse-rotated back to original orientation.

Key changes:
- Add orientation_anchor_parts parameter to inference pipeline
- Apply egocentric rotation per instance in CentroidCrop
- Store rotation angles and apply inverse rotation in FindInstancePeaks
- Fix coordinate transformation from crop to full image space

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

2 participants