Skip to content

Fix incorrect TFLite INT8 calibration guidance - #1364

Open
amanharshx wants to merge 4 commits into
roboflow:developfrom
amanharshx:fix/1363-tflite_int8_calibration_docs
Open

Fix incorrect TFLite INT8 calibration guidance#1364
amanharshx wants to merge 4 commits into
roboflow:developfrom
amanharshx:fix/1363-tflite_int8_calibration_docs

Conversation

@amanharshx

Copy link
Copy Markdown
Contributor

Fixes #1363.

Summary

TFLite quantization="int8" uses dynamic-range quantization: weights are quantized to INT8, activations remain floating point, and calibration data does not affect the generated models.

This PR removes the incorrect missing-calibration accuracy warning and updates the export documentation and docstrings. Public arguments, data preparation, quantization behavior, and static INT8 support remain unchanged.

Validation

  • TFLite export tests: 79 passed
  • Export test suite: 375 passed, 67 skipped
  • Ruff, formatting, codespell, and mypy on touched files pass

@amanharshx
amanharshx force-pushed the fix/1363-tflite_int8_calibration_docs branch from 7372b8a to 1c35b08 Compare August 18, 2026 06:19
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86%. Comparing base (48d6777) to head (4f2a0be).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #1364   +/-   ##
=======================================
- Coverage       86%     86%   -0%     
=======================================
  Files          111     111           
  Lines        14292   14290    -2     
=======================================
- Hits         12263   12261    -2     
  Misses        2029    2029           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda
Borda requested a balanced review from Copilot August 18, 2026 07:25
@Borda Borda added the bug Something isn't working label Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Corrects TFLite INT8 guidance to reflect dynamic-range quantization behavior.

Changes:

  • Removes the inaccurate missing-calibration warning.
  • Updates API documentation and export guidance.
  • Adjusts regression tests and changelog.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CHANGELOG.md Records the correction.
docs/learn/export.md Revises TFLite INT8 guidance.
src/rfdetr/detr.py Updates public export documentation.
src/rfdetr/export/main.py Clarifies conversion parameters.
src/rfdetr/export/_tflite/converter.py Removes warning and corrects internal documentation.
tests/export/test_tflite_export.py Updates calibration-data tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/learn/export.md Outdated
@Borda

Borda commented Aug 18, 2026

Copy link
Copy Markdown
Member

@amanharshx, I see mostly just doc changes, no code or dependency updates, so you say it was working all the time? I think I tried it and it did not work for me... 😕
btw, we know it shall work in theory, but in practice we hit some problems 🦝

@amanharshx

Copy link
Copy Markdown
Contributor Author

@Borda No, I’m not saying TFLite INT8 always worked end to end. This PR only fixes the calibration guidance. _quantize_dynamic_range() uses Optimize.DEFAULT without a representative_dataset, so calibration_data can’t change the generated model or fix an export failure.

I’ve hit separate export failures too. #1323 fixed the import-order deadlock and shipped in 1.9.3. I also reproduced a 1.9.3 PATH issue on macOS arm64 with Python 3.12, TensorFlow 2.19.1, and onnx2tf 2.4.3: invoking <venv>/bin/python without <venv>/bin on PATH prevents onnx2tf from launching onnxsim, and conversion later fails with the Functional-model error. Adding <venv>/bin to PATH makes the same export produce FP32 and FP16 models.

I have a fix and will file it separately with the full reproduction and logs. If what you hit was different, I’d be happy to have a look 🙂

@amanharshx
amanharshx force-pushed the fix/1363-tflite_int8_calibration_docs branch from 1c35b08 to f9a8442 Compare August 18, 2026 08:07
@Borda

Borda commented Aug 18, 2026

Copy link
Copy Markdown
Member

So let's add a cookbook with TFlite to validate all is fine now

Dynamic-range quantization derives scales from weights and does not use
calibration data. Remove false warning and correct documentation while
retaining public API and conversion behavior.

Fixes roboflow#1363
The reworded `calibration_data` description said "JPEG/PNG" directories, dropping
the BMP and WebP mention the removed section carried.
`_load_calibration_images()` matches `_IMAGE_EXTENSIONS`, which is `.jpg`,
`.jpeg`, `.png`, `.bmp`, `.webp`, so the shorter list presented supported inputs
as unsupported.
@amanharshx
amanharshx force-pushed the fix/1363-tflite_int8_calibration_docs branch from f9a8442 to e571792 Compare August 18, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TFLite INT8 docs and warning incorrectly require calibration data

3 participants