Image Classification
LiteRT
LiteRT
mediapipe
on-device
android
ios
web
python
flutter
vision
efficientnet
int8
fp32
Instructions to use litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0 with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 11,720 Bytes
a41ac2f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | ---
license: apache-2.0
library_name: litert
pipeline_tag: image-classification
datasets:
- imagenet-1k
tags:
- mediapipe
- litert
- tflite
- image-classification
- on-device
- android
- ios
- web
- python
- flutter
- vision
- efficientnet
- int8
- fp32
- arxiv:1905.11946
---
# MediaPipe EfficientNet-Lite0 (Image Classifier)
EfficientNet-Lite0 1,000-class ImageNet image classification models in full-integer INT8 (`efficientnet_lite0_int8.tflite`, 5.4 MB) and FP32 (`efficientnet_lite0_float32.tflite`, 18.6 MB), packaged with TFLite metadata and embedded class labels for the [MediaPipe Image Classifier (`ImageClassifier`)](https://developers.google.com/edge/mediapipe/solutions/vision/image_classifier) task and standalone [LiteRT](https://developers.google.com/edge/litert) inference.
<div style="border: 1px solid rgba(59, 130, 246, 0.28); background-color: rgba(59, 130, 246, 0.06); border-radius: 8px; padding: 12px 16px; margin: 16px 0;">
<p style="margin: 0 0 6px 0;"><strong>Documentation:</strong> <a href="https://developers.google.com/edge/mediapipe/solutions/vision/image_classifier">MediaPipe Image Classifier Docs</a></p>
<p style="margin: 0 0 6px 0;"><strong>Samples:</strong> <a href="https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_classification/android">Android</a> · <a href="https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_classification/ios">iOS</a> · <a href="https://colab.research.google.com/github/google-ai-edge/mediapipe-samples/blob/main/examples/image_classification/python/image_classifier.ipynb">Python Colab</a> · <a href="https://github.com/google-ai-edge/mediapipe-samples-web/blob/main/src/tasks/image-classifier.ts">Web</a> · <a href="https://github.com/google/flutter-mediapipe/tree/main/samples/vision/image_classifier">Flutter</a></p>
<p style="margin: 0;"><strong>Try live:</strong> <a href="https://google-ai-edge.github.io/mediapipe-samples-web/#/vision/image_classifier">Web Demo</a></p>
</div>
EfficientNet-Lite0 adapts the EfficientNet-B0 architecture for on-device edge inference by replacing swish activations with ReLU6, removing squeeze-and-excitation blocks, and fixing the stem and head while scaling width and depth. It is the recommended default model for the MediaPipe `ImageClassifier` task, balancing compact size, low latency, and 1,000-class ImageNet-1K accuracy.
### Which variant should I pick?
- **`efficientnet_lite0_int8.tflite` (5.4 MB, INT8):** Best for CPU execution (XNNPACK) and memory-constrained mobile, web, or embedded targets (≈2.3× faster on Pixel 6 CPU than FP32).
- **`efficientnet_lite0_float32.tflite` (18.6 MB, FP32):** Best when running on a mobile/desktop GPU delegate or when maximum unquantized floating-point fidelity is required.
### Embedded vs. Standalone Label Files
Both `.tflite` files embed `labels_without_background.txt` (**1,000 classes**, index `0` = `tench` through index `999` = `toilet tissue`) inside their `TFLITE_METADATA` zip trailer, so MediaPipe `ImageClassifier` populates `category_name` automatically with no external label file.
For convenience, this repository also includes [`labels.txt`](./labels.txt) as linked from the MediaPipe documentation. Note that `labels.txt` has **1,001 lines** (line 1 is `background`, lines 2–1001 are the 1,000 ImageNet classes); if you run the `.tflite` graph directly with `ai-edge-litert` rather than MediaPipe Tasks, map output index `i` (`0..999`) to `labels.txt` line `i + 2` (`labels.splitlines()[1:][i]`).
## Files
| File in Repo Root | Upstream Google Path | Precision | Size | SHA-256 |
|---|---|---|---:|---|
| [`efficientnet_lite0_int8.tflite`](https://huggingface.co/litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0/blob/main/efficientnet_lite0_int8.tflite) | `image_classifier/efficientnet_lite0/int8/latest/efficientnet_lite0.tflite` | `int8` | 5.43 MB (5,434,517 B) | `bc2ffe19c1118de0c0c2a9088992da5589722656e0fba81421385300a4a34b16` |
| [`efficientnet_lite0_float32.tflite`](https://huggingface.co/litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0/blob/main/efficientnet_lite0_float32.tflite) | `image_classifier/efficientnet_lite0/float32/latest/efficientnet_lite0.tflite` | `float32` | 18.58 MB (18,582,189 B) | `6c7ab0a6e5dcbf38a8c33b960996a55a3b4300b36a018c4545801de3a3c8bde0` |
### Companion Files in Repo Root
| File | Role | Size | SHA-256 |
|---|---|---:|---|
| [`labels.txt`](./labels.txt) | Label map | 10.5 KB (10,484 B) | `536feacc519de3d418de26b2effb4d75694a8c4c0063e36499a46fa8061e2da9` |
### Download
```bash
pip install -U huggingface_hub
hf download litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0 efficientnet_lite0_int8.tflite --local-dir .
hf download litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0 efficientnet_lite0_float32.tflite --local-dir .
```
## Inputs, Outputs, and Model Specifications
### `efficientnet_lite0_int8.tflite`
- Embedded `TFLITE_METADATA`: name `EfficientNet-lite image classifier (quantized)` · version `1` · author `MediaPipe` · packed associated files: `labels_without_background.txt`
| Direction | Tensor | Shape | Type | Notes |
|---|---|---|---|---|
| Input | `images` | `[1, 224, 224, 3]` | `uint8` | image — Input image to be classified. The expected image is 224 x 224, with three channels (red, blue, and green) per pixel. Each element in the tensor is a value between min and max, where (per-channel) min is [0] and max is [255]. — Normalization: `mean=[127.0], std=[128.0]` — Quantization: `scale=0.012566, zero_point=131` |
| Output | `Softmax` | `[1, 1000]` | `uint8` | probability — Probabilities of the 1000 labels respectively. — Quantization: `scale=0.00390625, zero_point=0` — Labels: `labels_without_background.txt` |
### `efficientnet_lite0_float32.tflite`
- Embedded `TFLITE_METADATA`: name `EfficientNet-lite image classifier` · version `1` · author `MediaPipe` · packed associated files: `labels_without_background.txt`
| Direction | Tensor | Shape | Type | Notes |
|---|---|---|---|---|
| Input | `images` | `[1, 224, 224, 3]` | `float32` | image — Input image to be classified. The expected image is 224 x 224, with three channels (red, blue, and green) per pixel. Each element in the tensor is a value between min and max, where (per-channel) min is [-0.9921875] and max is [1.0]. — Normalization: `mean=[127.0], std=[128.0]` |
| Output | `Softmax` | `[1, 1000]` | `float32` | probability — Probabilities of the 1000 labels respectively. — Labels: `labels_without_background.txt` |
## Use with MediaPipe Tasks
### Python Quickstart
```bash
pip install -U mediapipe huggingface_hub
```
```python
import mediapipe as mp
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="litert-community/MediaPipe-ImageClassifier-EfficientNet-Lite0",
filename="efficientnet_lite0_int8.tflite",
)
BaseOptions = mp.tasks.BaseOptions
ImageClassifier = mp.tasks.vision.ImageClassifier
ImageClassifierOptions = mp.tasks.vision.ImageClassifierOptions
VisionRunningMode = mp.tasks.vision.RunningMode
options = ImageClassifierOptions(
base_options=BaseOptions(model_asset_path=model_path),
running_mode=VisionRunningMode.IMAGE,
max_results=5,
)
with ImageClassifier.create_from_options(options) as runner:
mp_image = mp.Image.create_from_file("input.jpg")
result = runner.classify(mp_image)
for category in result.classifications[0].categories:
print(f"{category.category_name}: {category.score:.3f}")
```
### Cross-Platform Guides & Samples
- **Task overview & options:** [Image Classifier documentation](https://developers.google.com/edge/mediapipe/solutions/vision/image_classifier)
- **Platform setup guides:** [Python](https://developers.google.com/edge/mediapipe/solutions/setup_python) · [Web / JavaScript](https://developers.google.com/edge/mediapipe/solutions/setup_web) · [Android (Kotlin / Java)](https://developers.google.com/edge/mediapipe/solutions/setup_android) · [iOS (Swift)](https://developers.google.com/edge/mediapipe/solutions/setup_ios) · [Flutter (Dart)](https://developers.google.com/edge/mediapipe/solutions/setup_flutter)
- **Runnable sample apps:** [Web Demo](https://google-ai-edge.github.io/mediapipe-samples-web/#/vision/image_classifier) · [Web Source](https://github.com/google-ai-edge/mediapipe-samples-web/blob/main/src/tasks/image-classifier.ts) · [Android](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_classification/android) · [iOS](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_classification/ios) · [Python Notebook](https://colab.research.google.com/github/google-ai-edge/mediapipe-samples/blob/main/examples/image_classification/python/image_classifier.ipynb) · [Flutter](https://github.com/google/flutter-mediapipe/tree/main/samples/vision/image_classifier)
## Latency Benchmarks
End-to-end MediaPipe Task pipeline average latency reported by the [Image Classifier documentation](https://developers.google.com/edge/mediapipe/solutions/vision/image_classifier#benchmarks):
| Model Variant | Device | CPU Latency | GPU Latency |
|---|---|---:|---:|
| EfficientNet-Lite0 (int8) | Pixel 6 | 10.08 ms | — |
| EfficientNet-Lite0 (float 32) | Pixel 6 | 23.52 ms | 18.90 ms |
## Intended Use, Limitations, and Fairness
- **Intended applications:** General-purpose single-label classification of prominent everyday objects, animals, plants, vehicles, and scenes across the 1,000 ImageNet-1K categories on mobile, web, desktop, and embedded devices.
- **Limitations & considerations:**
- Closed-vocabulary classifier restricted to the 1,000 ImageNet-1K synsets; inputs outside those classes will still receive probability mass over the closest training categories.
- Assumes a single dominant subject near the center of a 224×224 crop; for multi-object scenes with localization, use an object detector such as `MediaPipe-ObjectDetector-EfficientDet-Lite0`.
- Not intended for safety-critical, medical, biometric, or high-stakes decision-making without task-specific fine-tuning and validation.
- Google does not publish a separate standalone fairness PDF for EfficientNet-Lite0 on the MediaPipe documentation page.
## Provenance
Every model binary in this repository is byte-identical (unmodified FlatBuffer weights and embedded `TFLITE_METADATA` bytes) to the official artifact served by Google from `storage.googleapis.com/mediapipe-models`.
| Repo File | Upstream URL | GCS Generation | Upstream `Last-Modified` | Pinned Bucket Version |
|---|---|---|---|---|
| `efficientnet_lite0_int8.tflite` | [`efficientnet_lite0.tflite`](https://storage.googleapis.com/mediapipe-models/image_classifier/efficientnet_lite0/int8/latest/efficientnet_lite0.tflite) | `1682480009628520` | Wed, 26 Apr 2023 03:33:29 GMT | `/1/` |
| `efficientnet_lite0_float32.tflite` | [`efficientnet_lite0.tflite`](https://storage.googleapis.com/mediapipe-models/image_classifier/efficientnet_lite0/float32/latest/efficientnet_lite0.tflite) | `1682480007624226` | Wed, 26 Apr 2023 03:33:27 GMT | `/1/` |
## License and Citation
- License: `apache-2.0` — Stated as Apache License, Version 2.0 (`http://www.apache.org/licenses/LICENSE-2.0`) in the embedded `TFLITE_METADATA` block of the `.tflite` model file(s).
### Citation
```bibtex
@inproceedings{tan2019efficientnet,
title = {EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks},
author = {Tan, Mingxing and Le, Quoc V.},
booktitle = {International Conference on Machine Learning (ICML)},
year = {2019},
url = {https://arxiv.org/abs/1905.11946}
}
```
|