File size: 7,359 Bytes
739202f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
library_name: litert
pipeline_tag: image-segmentation
tags:
- mediapipe
- litert
- tflite
- image-segmentation
- on-device
- android
- ios
- web
- python
- flutter
- deeplab-v3
- semantic-segmentation
- pascal-voc
- fp32
---

# MediaPipe DeepLab-v3 (Image Segmenter)

General-purpose DeepLab-v3 semantic segmentation model (`deeplab_v3.tflite`, 2.8 MB, FP32, `257 x 257` input) segmenting **21 Pascal VOC classes** (`background`, `person`, `cat`, `dog`, `potted plant`, vehicles, furniture) for the [MediaPipe Image Segmenter (`ImageSegmenter`)](https://developers.google.com/edge/mediapipe/solutions/vision/image_segmenter) task.

<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_segmenter">MediaPipe Image Segmenter 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_segmentation/android">Android</a> · <a href="https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_segmentation/ios">iOS</a> · <a href="https://colab.research.google.com/github/google-ai-edge/mediapipe-samples/blob/main/examples/image_segmentation/python/image_segmentation.ipynb">Python Colab</a> · <a href="https://github.com/google-ai-edge/mediapipe-samples-web/blob/main/src/tasks/image-segmenter.ts">Web</a> · <a href="https://github.com/google/flutter-mediapipe/tree/main/samples/vision/image_segmenter">Flutter</a></p>
  <p style="margin: 0;"><strong>Try live:</strong> <a href="https://google-ai-edge.github.io/mediapipe-samples-web/#/vision/image_segmenter">Web Demo</a></p>
</div>

Uses atrous spatial pyramid pooling (ASPP) over `[1, 257, 257, 3]` RGB input to produce `[1, 257, 257, 21]` per-pixel logits/probabilities. Embeds `labelmap.txt` / `labels.txt` in `TFLITE_METADATA`:

`0`: `background`, `1`: `aeroplane`, `2`: `bicycle`, `3`: `bird`, `4`: `boat`, `5`: `bottle`, `6`: `bus`, `7`: `car`, `8`: `cat`, `9`: `chair`, `10`: `cow`, `11`: `dining table`, `12`: `dog`, `13`: `horse`, `14`: `motorbike`, `15`: `person`, `16`: `potted plant`, `17`: `sheep`, `18`: `sofa`, `19`: `train`, `20`: `tv`.

## Files

| File | Precision | Size | SHA-256 |
|---|---|---:|---|
| [`deeplab_v3.tflite`](https://huggingface.co/litert-community/MediaPipe-ImageSegmenter-DeepLab-V3/blob/main/deeplab_v3.tflite) | `float32` | 2.78 MB (2,780,176 B) | `ff36e24d40547fe9e645e2f4e8745d1876d6e38b332d39a82f0bf0f5d1d561b3` |

### Download

```bash
pip install -U huggingface_hub
hf download litert-community/MediaPipe-ImageSegmenter-DeepLab-V3 deeplab_v3.tflite --local-dir .
```

## Inputs, Outputs, and Model Specifications

### `deeplab_v3.tflite`

- Embedded `TFLITE_METADATA`: name `ImageSegmenter` · version `1` · author `MediaPipe` · packed associated files: `labelmap.txt`, `labels.txt`

| Direction | Tensor | Shape | Type | Notes |
|---|---|---|---|---|
| Input | `sub_7` | `[1, 257, 257, 3]` | `float32` | image — Input image to be processed. — Normalization: `mean=[127.5], std=[127.5]` |
| Output | `ResizeBilinear_3` | `[1, 257, 257, 21]` | `float32` | segmentation_masks — Masks over the target objects with high accuracy. — Labels: `labels.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-ImageSegmenter-DeepLab-V3",
    filename="deeplab_v3.tflite",
)

BaseOptions = mp.tasks.BaseOptions
ImageSegmenter = mp.tasks.vision.ImageSegmenter
ImageSegmenterOptions = mp.tasks.vision.ImageSegmenterOptions
VisionRunningMode = mp.tasks.vision.RunningMode

options = ImageSegmenterOptions(
    base_options=BaseOptions(model_asset_path=model_path),
    running_mode=VisionRunningMode.IMAGE,
    output_category_mask=True,
    output_confidence_masks=False,
)

with ImageSegmenter.create_from_options(options) as runner:
    mp_image = mp.Image.create_from_file("input.jpg")
    result = runner.segment(mp_image)
    print("Category mask shape:", result.category_mask.numpy_view().shape)
```

### Cross-Platform Guides & Samples

- **Task overview & options:** [Image Segmenter documentation](https://developers.google.com/edge/mediapipe/solutions/vision/image_segmenter)
- **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_segmenter) · [Web Source](https://github.com/google-ai-edge/mediapipe-samples-web/blob/main/src/tasks/image-segmenter.ts) · [Android](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_segmentation/android) · [iOS](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_segmentation/ios) · [Python Notebook](https://colab.research.google.com/github/google-ai-edge/mediapipe-samples/blob/main/examples/image_segmentation/python/image_segmentation.ipynb) · [Flutter](https://github.com/google/flutter-mediapipe/tree/main/samples/vision/image_segmenter)

## Latency Benchmarks

End-to-end MediaPipe Task pipeline average latency reported by the [Image Segmenter documentation](https://developers.google.com/edge/mediapipe/solutions/vision/image_segmenter#benchmarks):

| Model Variant | Device | CPU Latency | GPU Latency |
|---|---|---:|---:|
| DeepLab-V3 | Pixel 6 | 123.93 ms | 103.30 ms |

## Intended Use, Limitations, and Fairness

- **Intended applications:** General-purpose scene segmentation across the 20 foreground Pascal VOC object classes plus background (photo effects, foreground extraction, scene understanding).
- **Limitations & considerations:** Restricted to the 21 Pascal VOC categories at `257 x 257` model resolution; fine boundaries or out-of-vocabulary objects are not separated. No standalone Google fairness PDF is published for DeepLab-v3 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 |
|---|---|---|---|---|
| `deeplab_v3.tflite` | [`deeplab_v3.tflite`](https://storage.googleapis.com/mediapipe-models/image_segmenter/deeplab_v3/float32/latest/deeplab_v3.tflite) | `1682480021097695` | Wed, 26 Apr 2023 03:33:41 GMT | `/1/` |

## License and Citation

- License: `apache-2.0` — Distributed under Apache License, Version 2.0 alongside the [MediaPipe](https://github.com/google-ai-edge/mediapipe) release artifacts.