Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

Add masked reconstruction branch to inference loop with entropy loss and geometric consistency#6

Open
Copilot wants to merge 6 commits intomainfrom
copilot/add-masked-reconstruction-branch
Open

Add masked reconstruction branch to inference loop with entropy loss and geometric consistency#6
Copilot wants to merge 6 commits intomainfrom
copilot/add-masked-reconstruction-branch

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

Implements geometry-aligned masked image modeling (MIM) in the inference path for test-time adaptation, with entropy minimization for geometric consistency.

Changes

Model extensions (rtdetr_pose/model.py):

  • RenderTeacher: Small CNN encoding mask+depth → geometry features
  • DecoderMIM: Reconstructs masked P5 neck features
  • RTDETRPose.forward() accepts geom_input (mask+normalized depth), feature_mask, return_mim flag
  • Automatic spatial resizing for mask/geometry inputs

Loss functions (rtdetr_pose/losses.py):

  • mim_reconstruction_loss(): L1 loss on masked regions between reconstructed and teacher features
  • entropy_loss(): Minimizes prediction entropy for confident geometric alignment
  • Losses class integrates both with configurable weights (0.1, 0.01)

API:

# Opt-in via flag (disabled by default)
model = RTDETRPose(enable_mim=True)

# Geometry input: [mask, log(depth/z_ref)]
geom = create_geom_input(mask, depth_obj)
mask_feat = generate_block_mask(h, w, mask_prob=0.6)

# Returns standard outputs + optional MIM branch
outputs = model(image, geom_input=geom, feature_mask=mask_feat, return_mim=True)

# MIM outputs: recon_feat, teacher_feat, entropy
loss = mim_reconstruction_loss(outputs["mim"]["recon_feat"], 
                                outputs["mim"]["teacher_feat"],
                                mask=outputs["mim"]["mask"])

Test-time training:
Adapt normalization parameters via MIM + entropy loss on unlabeled test images with predicted geometry.

Compatibility:
Zero overhead when enable_mim=False (default). Existing inference paths unchanged.

Implementation notes

  • Operates on P5 features (1/16 to 1/32 scale)
  • Teacher features use stopgrad() for stable supervision
  • Reference depth normalization: log(D_obj / median(D_obj))
  • ~100K additional parameters (RenderTeacher + DecoderMIM)

Implements RT-DETR 6DoF Spec v0.4 §6 (Geometry-Aligned MIM).

Original prompt

inference loop に masked reconstruction branc

entropy loss + geom consistency


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@thinksyncs thinksyncs marked this pull request as ready for review February 6, 2026 00:40
Copilot AI review requested due to automatic review settings February 6, 2026 00:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI and others added 3 commits February 6, 2026 00:42
…istency

Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
@thinksyncs thinksyncs self-requested a review February 6, 2026 00:47
Copilot AI and others added 2 commits February 6, 2026 00:48
Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
Co-authored-by: thinksyncs <42225585+thinksyncs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add masked reconstruction branch with entropy loss and geometric consistency Add masked reconstruction branch to inference loop with entropy loss and geometric consistency Feb 6, 2026
Copilot AI requested a review from thinksyncs February 6, 2026 00:52
Copilot AI added a commit that referenced this pull request Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants