feat(tflite): add private inference helpers and tests - #1011
Merged
Merged
Conversation
- `_create_interpreter`, `_run_inference`, `_softmax` in `export/_tflite/inference.py` - 14 mock-based tests in `tests/export/test_tflite_inference.py` --- Co-authored-by: Claude Code <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1011 +/- ##
=======================================
Coverage 80% 80%
=======================================
Files 100 101 +1
Lines 8447 8519 +72
=======================================
+ Hits 6774 6836 +62
- Misses 1673 1683 +10 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds lightweight, dependency-minimal TFLite inference helpers under rfdetr.export._tflite and introduces a dedicated unit test suite to validate interpreter creation and output decoding behavior for exported RF-DETR models.
Changes:
- Added
src/rfdetr/export/_tflite/inference.pywith private helper functions for interpreter creation, image preprocessing, and decoding TFLite outputs intosupervision.Detections. - Added
tests/export/test_tflite_inference.pywith mocked-interpreter tests covering backend fallback, preprocessing, thresholding, grayscale handling, and output reordering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/rfdetr/export/_tflite/inference.py |
Implements private TFLite interpreter + inference helpers (softmax, preprocessing, decoding). |
tests/export/test_tflite_inference.py |
Adds unit tests using mocks/temp images to validate the new inference helpers. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…py ignores
- Use od.get("name", "<unnamed>") in debug log (W2: KeyError guard)
- Fix test_logs_input_and_output_shapes to mock logger.debug (propagate=False blocks caplog)
- Add test_raises_for_non_float32_input_dtype covering new ValueError branch
- Add tflite_runtime/tensorflow to mypy ignore_missing_imports (optional deps)
---
Co-authored-by: Claude Code <noreply@anthropic.com>
Borda
commented
Apr 29, 2026
Borda
commented
Apr 29, 2026
Borda
commented
Apr 29, 2026
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
…tch.dict --- Co-authored-by: Claude Code <noreply@anthropic.com>
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.
This pull request introduces a new TFLite inference helper module for RF-DETR exported models, along with a comprehensive test suite. The main focus is to provide lightweight, dependency-minimal utilities for running inference on TFLite models outside the training stack, and to ensure robust and reliable operation through detailed unit tests.
Key additions and improvements:
TFLite Inference Utilities
src/rfdetr/export/_tflite/inference.py, which provides helper functions for TFLite model inference:_create_interpreter: Loads and prepares a TFLite interpreter, supporting bothtflite-runtimeandtensorflow.liteas backends, and prints input/output tensor shapes._run_inference: Handles image preprocessing (including normalization and resizing), runs inference, and decodes detection outputs into pixel-space bounding boxes using thesupervisionlibrary. Supports both RGB and grayscale images and is robust to output tensor ordering._softmaxfunction for post-processing logits.Comprehensive Testing
tests/export/test_tflite_inference.pywith detailed unit tests for the new inference helpers:Pathmodel paths.These changes make it easy to deploy and test RF-DETR TFLite models in environments where only minimal dependencies are available, and ensure correctness and robustness through thorough testing.