YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
TFLite ScoreThresholdingOptions Metadata Authority β PoC
Summary
This repository demonstrates that the MediaPipe Task Library ImageClassifier reads and applies
ScoreThresholdingOptions.global_score_threshold from a model's embedded TFLITE_METADATA FlatBuffer
as a fallback score filter during post-inference processing, without user visibility or warning.
An adversarially crafted model with global_score_threshold = 1e9 embedded in
outputTensorMetadata[0].process_units[] causes the classifier to return zero categories
silently β even though the model graph, weights, and inference scores are unchanged.
An explicit API score_threshold parameter overrides the metadata value and restores output,
confirming that metadata acts as the fallback authority when the API caller does not set
a threshold explicitly.
Affected consumer: MediaPipe Task Library ImageClassifier
Not affected: Raw TFLite Interpreter (does not apply ScoreThresholdingOptions)
Root: TensorMetadata.process_units[].ScoreThresholdingOptions.global_score_threshold
Runtime stage: Post-inference score filtering (output side)
Authority type: Fallback β API score_threshold overrides when explicitly set
Affected Consumer
The MediaPipe Task Library ImageClassifier automatically reads ScoreThresholdingOptions from
outputTensorMetadata[0].process_units[] in the model's TFLITE_METADATA FlatBuffer. This value
is used as the default score threshold when the API caller does not provide one:
import mediapipe as mp
from mediapipe.tasks import python
from mediapipe.tasks.python.vision import ImageClassifier, ImageClassifierOptions
opts = ImageClassifierOptions(
base_options = python.BaseOptions(model_asset_path="model.tflite"),
max_results = 10
# No score_threshold set β uses metadata fallback
)
Files
| File | Description |
|---|---|
reproduce_tflite_score_thresholding_suppression.py |
Reproduction script |
inspect_score_thresholding_hash_matrix.py |
Hash matrix inspection script |
*.pklM |
Model files |
requirements.txt |
Python dependencies |
SHA256SUMS.txt |
Checksums |
- Downloads last month
- -