-
Notifications
You must be signed in to change notification settings - Fork 0
Codex/continual learning v2 #10
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
Closed
Closed
Changes from all commits
Commits
Show all changes
160 commits
Select commit
Hold shift + click to select a range
89d6fb0
Update beads config and ignore list
fe9e5c7
Implement TensorRT exporter and build script
a5ff915
Add PNG mask loading in validator
0899ac9
Load PNG masks in training dataset
e26fe1a
Document PNG mask loading in train_minimal
935551c
Mark bbox format support complete
c695b61
Add TTA transform tests
082a822
Add target checks to latency benchmark
7d48ad4
Improve TRT builder input name
75661cf
Add TRT parity wrapper tool
a2fc9d5
Add TRT workflow helper
57c4952
Add MIM masking to train_minimal
14625c6
Add staged offset/K schedule
ef1d951
Add MIM teacher distillation
9e923a9
Expose backbone SPPF config
ca2f47a
Add TTT MIM runner
9f7f049
Add inference constraints gating
b046469
Log MIM ratio in training
3e4ccad
Add hybrid encoder level fusion
da38f1f
Integrate TTA into export_predictions
8072833
Add TTA runner base interface
ba0d271
Initial plan
Copilot 1c97f80
Fix linting errors by removing unused imports and configuring ruff
Copilot 4edbb63
Finish TTA tooling
c9e71c6
Gate depth loss by masks
8e49b9b
Merge pull request #2 from thinksyncs/copilot/fix-action-errors
thinksyncs c024edd
Add MIM mask schedule
3ca68c4
Add update filters for TTT params
75a4219
Add TTT integration plan
501325b
Mark staged offsets/K done
315124d
Add staged matcher cost schedule
60c4c4e
Mark SIM jitter integration done
dc1c001
Add training/inference/export docs
45a0e2d
Add CI scenario smoke run
6d24065
Add scenario report schema
050e314
Add scenario suite runner
a4587bc
Add low-FP gate helper
9800a3d
Mark constraints gating done
615101c
Add symmetry template verification
9f9d99f
Add inference utilities
b2fe9cb
Add denoising target augmentation
6f01f61
Export ONNX after training by default
628c6ba
Fix lint indentation in train_minimal
a900d70
Add yolozu train/test CLI
e4794a4
Add yolozu train/test CLI
9193c1e
Allow insecure SSL in coco128 fetch
a01a336
Use insecure SSL in CI fetch
a914833
Add metrics defaults and plotting support
106054b
Support mask-only labels
8b62a3d
Derive labels from masks
a130ca5
Add Pillow to requirements
f3a27d6
Add default YAML settings
cc488be
Add SGD and LR schedules
1f88857
Add predictions schema and adapter contract
98110f2
docs: refresh README/spec; clarify TTA/TTT; fix interface notes
aca5b0a
beads: add TTT integration remaining-work issues
9e01a7d
docs: clarify TTA is prediction-space transform
fcc3d1e
feat: add LoRA option to minimal trainer
e467577
feat: add TTT (--ttt) to export_predictions
4a21750
chore: bd sync
4ce0135
docs: highlight TTT and features in README
2e9d981
beads: add high-priority follow-up features
1c820ba
chore: bd sync
d436f39
docs: clarify intrinsics units and frames
5d5796e
feat: LBFGS calibrate depth scale and intrinsics delta
fd23b05
test: add PyTorch vs ONNXRuntime parity
e573547
beads: close YOLOZU-8wj
f1b2fbb
beads: sync
5a5c527
lint: fix torch typing refs
7583569
adapter: realistic rtdetr_pose preprocessing
27ed4c4
beads: close YOLOZU-4t3
68cfc59
beads: sync
2f22040
predictions: validate wrapped meta contract
4669288
beads: close YOLOZU-jmv
c281cb6
beads: sync
3866e9c
dataset: add quality validator
60fde28
Initial plan
Copilot 921c062
beads: close YOLOZU-eco
621a392
beads: sync
8dd4a56
Merge pull request #3 from thinksyncs/copilot/fix-issue-with-function…
thinksyncs 57decc0
reports: unify baseline output
432c91c
beads: close YOLOZU-vra
604d100
beads: sync
ea6efff
Initial plan
Copilot dc58f19
lora: add conv1x1 support
ebe9252
beads: close YOLOZU-59r
cbb5ffb
beads: sync
61bb1e4
ttt: add presets and compact reports
0946c12
beads: close YOLOZU-780
be79fdd
beads: sync
fec844c
Fix test failures: add onnxscript dependency and fix ONNX compatibility
Copilot 11256d7
Merge pull request #4 from thinksyncs/copilot/fix-issue
thinksyncs 190a339
Initial plan
Copilot 55fada0
Document TTT/Tent hooks in adapter contract
Copilot d36c5e7
Merge pull request #5 from thinksyncs/copilot/add-tent-hook-to-adapter
thinksyncs ae12dea
Initial plan
Copilot 3c69c0b
Merge PR #6: Add masked reconstruction branch to inference loop with …
Copilot 2a6289e
Merge PR #7: Add Hessian solver for per-detection regression head ref…
Copilot ac3f6ad
Merge PR #8: Add gradient accumulation and AMP to training scaffold (…
Copilot 2f77223
Merge PR #9: Document lint errors (already fixed in PR #8 merge)
Copilot b883836
Fix all linting errors from merged PRs
Copilot a523e61
Update SECURITY_SUMMARY.md to reflect all consolidated PRs
Copilot 4b11323
Merge pull request #10 from thinksyncs/copilot/combine-all-prs
thinksyncs 3b8b5e6
Initial plan
Copilot 82870d1
Add optimizer and scheduler factory modules with EMA support
Copilot 801fc2d
Add unit tests and update documentation for optimizer/scheduler features
Copilot 945d47a
Fix linting issues in factory modules and tests
Copilot 93d1efc
Merge pull request #11 from thinksyncs/copilot/add-configurable-optim…
thinksyncs 9e34623
Initial plan
Copilot e3bea29
Fix PR#12 review issues: warmup logic, state persistence, OneCycleLR,…
Copilot 3d63c5a
Improve EMA error message clarity based on code review feedback
Copilot a1f0fca
Add comprehensive summary of PR#12 review fixes
Copilot 54fff5f
Merge pull request #13 from thinksyncs/copilot/revise-pr-error-fix
thinksyncs 6152554
Merge origin/main into thinksyncs/main
b97c956
Merge origin/main into thinksyncs/main
3d97063
feat(dataset): add VOC/ADE20K seg prepare tools
9a9da23
feat(seg): add contracts and mIoU evaluator
967a0b9
fix(lint): resolve ruff F821/F811
becce64
feat(intrinsics): support OpenCV camera_matrix
95321e9
docs: refresh README
b2265e3
feat: continual learning runner + eval
0ac6ff2
Add instance-seg PNG eval tool
3db728e
Add instance-seg demo + validator
1586d2c
Improve instance-seg eval diagnostics
be4f7af
Add COCO instance-seg prediction converter
58d674a
Add yolozu eval-instance-seg subcommand
c719714
Add README ON/OFF comparison image
f55e54e
Add allow-rgb-masks demo asset
5e3e128
Replace README option images with plots
aa7ffe8
Remove unconvincing demo plots from README
35d4661
Add TTT presets and subset dataset tool
cfaa6f6
TTT: restore norm buffers on rollback/reset
44a0a0c
README: remove instance-seg overlay image
72b4ad0
docs: remove unused instance-seg overlay asset
e2cd095
Keypoints: YOLO pose labels + PCK eval tool
4db64e5
chore(beads): close YOLOZU-a1e
f287a28
feat(keypoints): add OKS mAP + parity + benchmark
98c2e35
chore(beads): close YOLOZU-9uj
d3435ea
feat(license): add dependency license report
faffc5d
chore(beads): close YOLOZU-3v6
0b44d64
docs(runpod): pin yolozu TRT tag + add compliance script
8d5fd07
chore(beads): close YOLOZU-0md
cd8efec
chore(notice): use ToppyMicroServices OÜ
d374df8
chore(beads): close YOLOZU-hhf
ce297e1
chore(beads): claim YOLOZU-aa9
aab0acd
tests: add CUDA smoke for rtdetr_pose export
c5e1ddf
chore: avoid beads state in CUDA test PR
ccf08a2
chore: keep beads sync out of code branch
3728906
chore: revert beads JSONL from code PR
1e26df0
feat: add LoRA options + Hessian CLI smoke tests
69848c2
Beads: close YOLOZU-g6s
33781f9
fix: default lora-freeze-base off
7c72b20
feat(intrinsics): parse OpenCV-style K
8effc17
fix: remove duplicate lora guard
7bc9c8f
chore(beads): close YOLOZU-aa9
46262c0
feat: rtdetr_pose trt parity+benchmark runner
e5ea4c6
chore(beads): start YOLOZU-6lb
0e85bf3
feat(ttt): safe presets by default
f411a3b
chore(beads): ignore sync staging dir
6bbc4e3
YOLOZU-n97: pose eval + replay controls for continual learning
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| # Implementation Summary: Masked Reconstruction Branch in Inference Loop | ||
|
|
||
| **Issue**: Add inference loop に masked reconstruction branch + entropy loss + geom consistency | ||
|
|
||
| **Status**: ✅ COMPLETED | ||
|
|
||
| ## Overview | ||
|
|
||
| Successfully implemented a masked reconstruction branch for the inference loop with entropy loss and geometric consistency, as specified in the RT-DETR 6DoF Geometry-Aligned MIM specification (Section 6). | ||
|
|
||
| ## Key Deliverables | ||
|
|
||
| ### 1. Model Components (rtdetr_pose/rtdetr_pose/model.py) | ||
|
|
||
| **RenderTeacher** (Lines 295-326) | ||
| - Small CNN that processes geometry tensors (mask + normalized depth) | ||
| - Produces teacher features for masked reconstruction supervision | ||
| - 3-layer architecture: conv1 → conv2 → conv3 | ||
|
|
||
| **DecoderMIM** (Lines 329-360) | ||
| - Reconstruction decoder for masked features | ||
| - Processes masked neck features and outputs reconstructed features | ||
| - Simple 2-conv + output architecture | ||
|
|
||
| **RTDETRPose Enhancements** (Lines 362-513) | ||
| - New `enable_mim` parameter to optionally enable MIM branch (default: False) | ||
| - New `mim_geom_channels` parameter for geometry input channels (default: 2) | ||
| - Enhanced `forward()` method supports: | ||
| - `geom_input`: Geometry input (mask + depth) for teacher | ||
| - `feature_mask`: Mask for feature masking | ||
| - `return_mim`: Flag to enable MIM outputs (default: False) | ||
| - Automatic resizing of masks and geometry to match feature dimensions | ||
| - Uses P5 neck features for reconstruction | ||
| - Computes entropy loss for geometric consistency | ||
|
|
||
| ### 2. Loss Functions (rtdetr_pose/rtdetr_pose/losses.py) | ||
|
|
||
| **mim_reconstruction_loss()** (Lines 93-124) | ||
| - L1 loss between reconstructed and teacher features | ||
| - Supports optional masking (compute loss only on masked locations) | ||
| - Handles missing teacher features gracefully | ||
|
|
||
| **entropy_loss()** (Lines 127-141) | ||
| - Entropy minimization for geometric consistency | ||
| - Lower entropy = more confident predictions | ||
| - Computed on classification logits | ||
|
|
||
| **Losses Class Updates** (Lines 143-457) | ||
| - Added `mim` weight (default: 0.1) | ||
| - Added `entropy` weight (default: 0.01) | ||
| - Integrated MIM loss computation in forward pass | ||
|
|
||
| ### 3. Tests (tests/test_mim_reconstruction.py) | ||
|
|
||
| **10 Comprehensive Tests** (All Passing ✅) | ||
| 1. `test_render_teacher_forward`: RenderTeacher output shape | ||
| 2. `test_decoder_mim_forward`: DecoderMIM output shape | ||
| 3. `test_model_with_mim_enabled`: Model initialization with MIM | ||
| 4. `test_model_without_mim`: Model initialization without MIM | ||
| 5. `test_forward_with_mim`: Forward pass with MIM branch | ||
| 6. `test_forward_without_mim`: Forward pass without MIM | ||
| 7. `test_mim_reconstruction_loss`: MIM loss with/without mask | ||
| 8. `test_mim_reconstruction_loss_no_teacher`: MIM loss edge case | ||
| 9. `test_entropy_loss`: Entropy loss computation | ||
| 10. `test_losses_with_mim`: Losses class integration | ||
|
|
||
| ### 4. Documentation | ||
|
|
||
| **docs/mim_inference.md** (7KB) | ||
| - Complete usage guide | ||
| - Component descriptions | ||
| - Training and inference examples | ||
| - Test-time training integration | ||
| - Geometric consistency details | ||
| - Performance considerations | ||
|
|
||
| **tools/example_mim_inference.py** (8KB) | ||
| - Working example script | ||
| - Supports inference with/without TTT | ||
| - Command-line interface | ||
| - Demonstrates geometry input creation | ||
| - Shows TTT adaptation loop | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| ### Backward Compatibility | ||
|
|
||
| ✅ **Fully Backward Compatible** | ||
| - Default behavior unchanged: `enable_mim=False` | ||
| - Models without MIM work exactly as before | ||
| - Only when `enable_mim=True` AND `return_mim=True` are MIM outputs included | ||
|
|
||
| ### Geometric Consistency | ||
|
|
||
| The implementation enforces geometric consistency through: | ||
|
|
||
| 1. **Teacher Features**: Derived from actual geometry (mask + normalized depth) | ||
| - Reference depth: `z_ref = median(D_obj[M==1])` | ||
| - Normalized depth: `D_norm = M * (log(D_obj + ε) - log(z_ref + ε))` | ||
| - Teacher input: `concat(M, D_norm)` | ||
|
|
||
| 2. **Entropy Minimization**: Forces confident predictions that align with geometry | ||
| - Lower entropy → More confident predictions | ||
| - Weight: 0.01 (tunable) | ||
|
|
||
| 3. **Masked Reconstruction**: Forces model to understand geometric structure | ||
| - Reconstructs masked neck features (P5 level) | ||
| - Supervised by geometry-derived teacher features | ||
| - Loss computed only on masked regions | ||
|
|
||
| ### Test-Time Training (TTT) | ||
|
|
||
| The MIM branch supports test-time adaptation: | ||
|
|
||
| ```python | ||
| # Adapt model parameters using MIM loss | ||
| for step in range(num_steps): | ||
| outputs = model(image, geom_input=geom, feature_mask=mask, return_mim=True) | ||
| loss = mim_loss + 0.1 * entropy_loss | ||
| loss.backward() | ||
| optimizer.step() | ||
| ``` | ||
|
|
||
| Observed behavior: | ||
| - Entropy: 4.22 → 4.21 after 2 adaptation steps | ||
| - MIM loss decreases during adaptation | ||
| - Model becomes more confident in predictions | ||
|
|
||
| ## Testing Results | ||
|
|
||
| ### Unit Tests | ||
| - ✅ 10/10 new MIM tests passing | ||
| - ✅ 48/48 existing rtdetr_pose tests passing | ||
| - ✅ All TTT/TTA tests passing (17 tests) | ||
|
|
||
| ### Integration Tests | ||
| - ✅ Example script runs successfully | ||
| - ✅ TTT mode verified | ||
| - ✅ Backward compatibility verified | ||
|
|
||
| ### Security | ||
| - ✅ CodeQL scan: 0 alerts | ||
| - ✅ No security vulnerabilities introduced | ||
|
|
||
| ## File Changes | ||
|
|
||
| ``` | ||
| Modified: | ||
| rtdetr_pose/rtdetr_pose/model.py (+154 lines) | ||
| rtdetr_pose/rtdetr_pose/losses.py (+87 lines) | ||
|
|
||
| Added: | ||
| tests/test_mim_reconstruction.py (+230 lines) | ||
| docs/mim_inference.md (+177 lines) | ||
| tools/example_mim_inference.py (+200 lines) | ||
| ``` | ||
|
|
||
| **Total**: +848 lines of production code, tests, and documentation | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Basic Inference with MIM | ||
|
|
||
| ```python | ||
| from rtdetr_pose.model import RTDETRPose | ||
|
|
||
| # Create model with MIM enabled | ||
| model = RTDETRPose(enable_mim=True) | ||
|
|
||
| # Prepare inputs | ||
| image = torch.randn(1, 3, 640, 640) | ||
| geom_input = create_geometry_input(mask, depth) # (1, 2, H, W) | ||
| feature_mask = generate_block_mask(H, W, mask_prob=0.6) | ||
|
|
||
| # Forward with MIM | ||
| outputs = model(image, geom_input=geom_input, | ||
| feature_mask=feature_mask, return_mim=True) | ||
|
|
||
| # Access outputs | ||
| detections = outputs["logits"] | ||
| entropy = outputs["mim"]["entropy"] | ||
| recon_feat = outputs["mim"]["recon_feat"] | ||
| ``` | ||
|
|
||
| ### Test-Time Training | ||
|
|
||
| See `tools/example_mim_inference.py --ttt` for complete example. | ||
|
|
||
| ## Performance Considerations | ||
|
|
||
| - **Memory**: MIM branch adds ~2 small CNNs (RenderTeacher + DecoderMIM) | ||
| - **Compute**: Only active when `return_mim=True` | ||
| - **Zero overhead**: When `enable_mim=False`, no additional memory or compute | ||
| - **Feature level**: Operates on P5 neck features (typically 1/16 or 1/32 of input) | ||
|
|
||
| ## References | ||
|
|
||
| - Specification: `rt_detr_6dof_geom_mim_spec_en_v0_4.md` Section 6 | ||
| - Related: Tent TTT (entropy minimization) | ||
| - Related: MAE/BEiT (masked image modeling) | ||
|
|
||
| ## Conclusion | ||
|
|
||
| ✅ Successfully implemented all requirements: | ||
| 1. ✅ Masked reconstruction branch in inference loop | ||
| 2. ✅ Entropy loss for geometric consistency | ||
| 3. ✅ Geometric consistency through teacher features | ||
| 4. ✅ Full backward compatibility | ||
| 5. ✅ Comprehensive tests and documentation | ||
| 6. ✅ Working examples with TTT support | ||
|
|
||
| The implementation follows the specification closely and integrates cleanly with the existing codebase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Linting Fixes Needed for Open PRs | ||
|
|
||
| ## Summary | ||
| This document lists the linting errors found in currently open PRs that need to be fixed before they can be merged. | ||
|
|
||
| ## PR #8: copilot/implement-gradient-clipping | ||
|
|
||
| **Status**: Failed CI - Lint Step | ||
|
|
||
| **Error**: F401 - Unused import | ||
|
|
||
| **File**: `rtdetr_pose/tests/test_train_minimal_integration.py` | ||
|
|
||
| **Line**: 2 | ||
|
|
||
| **Issue**: `json` module is imported but never used | ||
|
|
||
| **Fix**: Remove the unused import on line 2 | ||
|
|
||
| ```diff | ||
| import importlib.util | ||
| -import json | ||
| import tempfile | ||
| import unittest | ||
| from pathlib import Path | ||
| ``` | ||
|
|
||
| **CI Log Reference**: Workflow run 21734491317 | ||
|
|
||
| ## How to Apply Fixes | ||
|
|
||
| For PR maintainers: | ||
|
|
||
| 1. Checkout the PR branch | ||
| 2. Apply the fix shown above | ||
| 3. Run `ruff check .` to verify | ||
| 4. Commit and push | ||
|
|
||
| For reviewers: | ||
|
|
||
| The fix is straightforward and can be automated with: | ||
| ```bash | ||
| ruff check --fix . | ||
| ``` | ||
|
|
||
| ## Additional Notes | ||
|
|
||
| - All other checked PRs (#6, #7) either pass linting or have not been fully analyzed yet | ||
| - The main branch (d36c5e7) passes all linting checks | ||
| - This PR (#9) documents these findings and passes linting itself |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| YOLOZU | ||
|
|
||
| Copyright 2026 ToppyMicroServices OÜ and contributors. | ||
|
|
||
| This product includes software developed for the YOLOZU project. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI now depends on a network download of coco128 at runtime, which can introduce flakiness, slowdowns, and failures in restricted environments. Consider caching the dataset artifact, vendoring a tiny deterministic test dataset, or making this step conditional (e.g., scheduled/nightly or
continue-on-error) so core CI remains reliable.