Skip to content

TFLite INT8 docs and warning incorrectly require calibration data #1363

Description

@amanharshx

Search before asking

  • I searched the RF-DETR issues and found no similar bug report.

#1024 discusses export formats broadly but does not track this problem.

Bug

RF-DETR’s TFLite documentation says INT8 export requires representative calibration images for good accuracy. Export also warns that omitting calibration_data will produce poor quantization accuracy.

RF-DETR does not use calibration for INT8 export. quantization="int8" produces a dynamic-range model with INT8 weights and floating-point activations.

Actual behavior:

model.export(
    format="tflite",
    quantization="int8",
    calibration_data=None,
)

Export succeeds and produces a *_dynamic_range_quant.tflite artifact, but logs:

No calibration_data provided for INT8 quantization. Using random data — this will produce poor quantization accuracy.

That warning is incorrect. _quantize_dynamic_range() sets only:

converter.optimizations = [tf.lite.Optimize.DEFAULT]

It never sets converter.representative_dataset. RF-DETR also never passes output_integer_quantized_tflite to onnx2tf, so calibration data cannot affect the generated INT8 model.

I also checked every currently supported onnx2tf release (2.4.0–2.4.3). None defines the download_test_image_data() function that _patch_validation_download() tries to patch, so supplied calibration_data does not currently reach onnx2tf validation either.

Expected behavior:

  • Do not warn when calibration_data is omitted.
  • Document "int8" as dynamic-range quantization that needs no calibration data.
  • Describe calibration_data and max_images according to their current behavior.
  • Keep static/full-integer INT8 unsupported.

Environment

  • RF-DETR 1.9.3
  • develop at 50f21220
  • Python 3.12
  • onnx2tf 2.4.3

Minimal Reproducible Example

from rfdetr import RFDETRSmall

model = RFDETRSmall()
model.export(
    format="tflite",
    quantization="int8",
    calibration_data=None,
)

Are you willing to submit a PR?

  • Yes, I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions