Merge main into feat/hailo-patchcore-e2e - #167
Closed
DeepKnowledge1 wants to merge 48 commits into
Closed
Conversation
…, localization, Autopilot support, and testing fixes (#166) ## 🔗 Related Issue Fixes # ## 📝 Description This PR adds **EfficientAD support to AnomaVision** and integrates it into the existing anomaly-detection pipeline alongside PaDiM and PatchCore. ### 🚀 EfficientAD * Added EfficientAD as a supported anomaly-detection algorithm. * Integrated EfficientAD with the existing algorithm abstraction used by PaDiM/PatchCore. * Reused the existing AnomaVision data loading and preprocessing pipeline. * Added batched training/inference to avoid unnecessary repeated computation. * Optimized teacher feature extraction and removed unnecessary inference-time computation. * Added calibrated anomaly thresholds based on **normal training images only**. * Added anomaly-map generation for pixel-level localization. * Reused the existing post-processing and visualization pipeline for: * anomaly heatmaps * localization masks * contours * bounding boxes * overlay visualizations ### 🔌 Deployment & Export * Added EfficientAD support to the existing model/export workflow. * Maintained compatibility with the existing ONNX-based detection flow. * Preserved the existing PaDiM/PatchCore inference architecture rather than introducing a separate EfficientAD pipeline. * Added EfficientAD support to **Production Autopilot**. * Autopilot can compare PaDiM, PatchCore, and EfficientAD candidates. * EfficientAD calibration data is preserved with the model artifact. ### 📊 Production Autopilot * Restored and preserved the rich `production_autopilot_report.html` dashboard. * Added EfficientAD to candidate comparison and model selection. * Report includes: * Image AUROC * Pixel AUROC * median latency * P95 latency * anomaly coverage * normal false-positive localization rate * threshold * selected model * deployment artifact * localization health * reproducibility information * Restored the existing timing/performance summary in the detection pipeline. ### 🐛 Fixes * Fixed EfficientAD training failure caused by PyTorch inference-mode tensors being used in autograd. * Fixed JSON serialization of NumPy/PyTorch scalar metrics in the Autopilot deployment manifest. * Restored Autopilot report/test compatibility. * Preserved existing helper APIs such as `_format_metric`. * Fixed report metric naming/capitalization expected by the test suite. ## 🔄 Type of Change * [x] 🐛 Bug fix (non-breaking change which fixes an issue) * [x] 🚀 New feature (non-breaking change which adds functionality) * [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) * [ ] 📖 Documentation update * [ ] 🏗️ Infrastructure / CI/CD update ## 🧪 Hardware & Matrix Testing **I have successfully built and tested this code using `uv` on:** * [x] `anomavision[cpu]` (Standard/Edge) * [ ] `anomavision[cu121]` (CUDA 12.1) * [ ] `anomavision[cu124]` (CUDA 12.4) * [ ] `anomavision[cu118]` (CUDA 11.8) **Host OS used for testing:** * [ ] Linux / Ubuntu * [x] Windows (Native or WSL2) * [ ] macOS ## 🧪 Validation * [x] Existing Autopilot unit tests updated/fixed. * [x] EfficientAD-specific integration changes covered. * [x] Autopilot report generation validated. * [x] Deployment manifest generation validated. * [ ] Full `uv run pytest` suite verified on all supported environments. * [ ] Bottle dataset benchmark completed for PaDiM vs PatchCore vs EfficientAD. * [ ] Full ONNX/OpenVINO/TensorRT/Hailo hardware validation completed. ## ✅ Developer Checklist * [x] My code follows the core style guidelines of this project (Ruff/Black formatting). * [ ] I have run `uv run pytest` and all unit tests pass locally. * [ ] **Lockfile Guard:** If I added or modified a dependency in `pyproject.toml`, I have run `uv lock --python 3.10` and committed the updated `uv.lock` file. * [x] I have added tests that prove my fix is effective or that my feature works. * [x] I have updated the documentation accordingly (if applicable). ## 📸 Screenshots / Visual Proof The Production Autopilot report now provides a rich HTML dashboard comparing PaDiM, PatchCore, and EfficientAD, including localization and deployment metrics. Recommended screenshots: * `production_autopilot_report.html` * EfficientAD anomaly heatmap * EfficientAD localization mask/overlay * PaDiM vs PatchCore vs EfficientAD comparison * Autopilot model-selection summary
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Sync the Hailo PatchCore E2E branch with the latest
main. Keep the existing Hailo-specific changes and avoid unrelated modifications.