A command-line tool to analyze TensorFlow Lite models for embedded ML applications.
- Metadata Extraction: Model size, architecture, input/output shapes, quantization type
- Weight Analysis: Statistical analysis of model weights with anomaly detection
- Quantization Detection: Automatically identifies float32, float16, int8, and mixed quantization
python -m venv tflite_venv
source tflite_venv/bin/activate # On Windows: tflite_venv\Scripts\activate
pip install -r requirements.txtBasic scan:
python src/cli.py model.tfliteSkip weight analysis (faster):
python src/cli.py model.tflite --skip-weights============================================================
MODEL METADATA
============================================================
Size: 0.42 MB (438,476 bytes)
Tensors: 8
Input shape: (1, 784)
Output shape: (1, 10)
Quantization: float32
Operators: MatMul
============================================================
WEIGHT ANALYSIS
============================================================
Total parameters: 109,184
Weight tensors analyzed: 3
No anomalies detected
============================================================
SUMMARY
============================================================
Status: PASS
Errors: 0
Warnings: 0
The scanner detects:
- All zeros: Weight layer is entirely zeros (model broken)
- Constant weights: All weights identical (initialization failed)
- Extreme sparsity: >99.5% weights are zero (unusual pruning)
- High sparsity: >95% weights are zero (may be intentional)
- Unusual range: Weight values outside typical range
pytest tests/Generate test models:
python tests/generate_test_models.pyInspect models:
python tests/inspect_models.py- 0: Success (no issues)
- 1: File not found
- 2: Invalid model format
- 10: Warnings found
- 20: Critical errors found
- 99: Unexpected error
src/
├── cli.py # Command-line interface
├── core/
│ ├── model_loader.py # Model loading and validation
│ └── exceptions.py # Custom exceptions
├── analyzers/
│ ├── metadata.py # Metadata extraction
│ └── weights.py # Weight analysis
└── reporting/
└── text_reporter.py # Output formatting
MIT