schmidt-sebastian commited on
Commit
22c1175
·
0 Parent(s):

Initial upload of MediaPipe-TextClassifier-AverageWord from MediaPipe Solutions

Browse files
Files changed (3) hide show
  1. .gitattributes +38 -0
  2. README.md +118 -0
  3. average_word_classifier.tflite +3 -0
.gitattributes ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.litertlm filter=lfs diff=lfs merge=lfs -text
12
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
+ *.model filter=lfs diff=lfs merge=lfs -text
14
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
15
+ *.npy filter=lfs diff=lfs merge=lfs -text
16
+ *.npz filter=lfs diff=lfs merge=lfs -text
17
+ *.onnx filter=lfs diff=lfs merge=lfs -text
18
+ *.ot filter=lfs diff=lfs merge=lfs -text
19
+ *.parquet filter=lfs diff=lfs merge=lfs -text
20
+ *.pb filter=lfs diff=lfs merge=lfs -text
21
+ *.pdf filter=lfs diff=lfs merge=lfs -text
22
+ *.pickle filter=lfs diff=lfs merge=lfs -text
23
+ *.pkl filter=lfs diff=lfs merge=lfs -text
24
+ *.pt filter=lfs diff=lfs merge=lfs -text
25
+ *.pth filter=lfs diff=lfs merge=lfs -text
26
+ *.rar filter=lfs diff=lfs merge=lfs -text
27
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
28
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar filter=lfs diff=lfs merge=lfs -text
31
+ *.task filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: litert
4
+ pipeline_tag: text-classification
5
+ language:
6
+ - en
7
+ tags:
8
+ - mediapipe
9
+ - litert
10
+ - tflite
11
+ - text-classification
12
+ - on-device
13
+ - android
14
+ - ios
15
+ - web
16
+ - python
17
+ - flutter
18
+ - nlp
19
+ - sentiment-analysis
20
+ - sst-2
21
+ - average-word-embedding
22
+ - fp32
23
+ ---
24
+
25
+ # MediaPipe Text Classifier (Average Word Embedding)
26
+
27
+ On-device English sentiment classification model (`average_word_classifier.tflite`, 776 KB) trained on Stanford Sentiment Treebank (SST-2) movie reviews for the [MediaPipe Text Classifier (`TextClassifier`)](https://developers.google.com/edge/mediapipe/solutions/text/text_classifier) task.
28
+
29
+ <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;">
30
+ <p style="margin: 0 0 6px 0;"><strong>Documentation:</strong> <a href="https://developers.google.com/edge/mediapipe/solutions/text/text_classifier">MediaPipe Text Classifier Docs</a></p>
31
+ <p style="margin: 0 0 6px 0;"><strong>Samples:</strong> <a href="https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/text_classification/android">Android</a> · <a href="https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/text_classification/ios">iOS</a> · <a href="https://colab.research.google.com/github/google-ai-edge/mediapipe-samples/blob/main/examples/text_classification/python/text_classifier.ipynb">Python Colab</a> · <a href="https://github.com/google-ai-edge/mediapipe-samples-web/blob/main/src/tasks/text-classifier.ts">Web</a> · <a href="https://github.com/google/flutter-mediapipe/tree/main/samples/text/text_classifier">Flutter</a></p>
32
+ <p style="margin: 0;"><strong>Try live:</strong> <a href="https://google-ai-edge.github.io/mediapipe-samples-web/#/text/text_classifier">Web Demo</a></p>
33
+ </div>
34
+
35
+ Ultra-fast continuous bag-of-words / average word-embedding classifier (`776 KB`, FP32, `[−1, 256]` input) trained on SST-2 (`0` = negative, `1` = positive), embedding a 10,003-entry regex `vocab.txt` (`<PAD>`, `<START>`, `<UNKNOWN>`, plus vocabulary words) and `labels.txt` inside `TFLITE_METADATA`.
36
+
37
+ ## Files
38
+
39
+ | File | Precision | Size | SHA-256 |
40
+ |---|---|---:|---|
41
+ | [`average_word_classifier.tflite`](https://huggingface.co/litert-community/MediaPipe-TextClassifier-AverageWord/blob/main/average_word_classifier.tflite) | `float32` | 775.7 KB (775,706 B) | `13bf6f7f35964f1e85d6cc762ee7b1952009b532b233baa5bdb4bf7441097f34` |
42
+
43
+ ### Download
44
+
45
+ ```bash
46
+ pip install -U huggingface_hub
47
+ hf download litert-community/MediaPipe-TextClassifier-AverageWord average_word_classifier.tflite --local-dir .
48
+ ```
49
+
50
+ ## Inputs, Outputs, and Model Specifications
51
+
52
+ ### `average_word_classifier.tflite`
53
+
54
+ - Embedded `TFLITE_METADATA`: name `TextClassifier` · version `1` · author `MediaPipe` · packed associated files: `vocab.txt`, `labels.txt`
55
+
56
+ | Direction | Tensor | Shape | Type | Notes |
57
+ |---|---|---|---|---|
58
+ | Input | `serving_default_input_1:0` | `[-1, 256]` | `int32` | input_text — Embedding vectors representing the input text to be processed. |
59
+ | Output | `StatefulPartitionedCall:0` | `[-1, 2]` | `float32` | score — Score of the labels respectively. — Labels: `labels.txt` |
60
+
61
+ ## Use with MediaPipe Tasks
62
+
63
+ ### Python Quickstart
64
+
65
+ ```bash
66
+ pip install -U mediapipe huggingface_hub
67
+ ```
68
+
69
+ ```python
70
+ import mediapipe as mp
71
+ from huggingface_hub import hf_hub_download
72
+
73
+ model_path = hf_hub_download(repo_id="litert-community/MediaPipe-TextClassifier-AverageWord", filename="average_word_classifier.tflite")
74
+
75
+ BaseOptions = mp.tasks.BaseOptions
76
+ TextClassifier = mp.tasks.text.TextClassifier
77
+ TextClassifierOptions = mp.tasks.text.TextClassifierOptions
78
+
79
+ options = TextClassifierOptions(base_options=BaseOptions(model_asset_path=model_path))
80
+ with TextClassifier.create_from_options(options) as classifier:
81
+ result = classifier.classify("An unforgettable and genuinely moving film!")
82
+ for cat in result.classifications[0].categories:
83
+ print(f"{cat.category_name}: {cat.score:.3f}")
84
+ ```
85
+
86
+ ### Cross-Platform Guides & Samples
87
+
88
+ - **Task overview & options:** [Text Classifier documentation](https://developers.google.com/edge/mediapipe/solutions/text/text_classifier)
89
+ - **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)
90
+ - **Runnable sample apps:** [Web Demo](https://google-ai-edge.github.io/mediapipe-samples-web/#/text/text_classifier) · [Web Source](https://github.com/google-ai-edge/mediapipe-samples-web/blob/main/src/tasks/text-classifier.ts) · [Android](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/text_classification/android) · [iOS](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/text_classification/ios) · [Python Notebook](https://colab.research.google.com/github/google-ai-edge/mediapipe-samples/blob/main/examples/text_classification/python/text_classifier.ipynb) · [Flutter](https://github.com/google/flutter-mediapipe/tree/main/samples/text/text_classifier)
91
+
92
+ ## Latency Benchmarks
93
+
94
+ End-to-end MediaPipe Task pipeline average latency reported by the [Text Classifier documentation](https://developers.google.com/edge/mediapipe/solutions/text/text_classifier#benchmarks):
95
+
96
+ | Model Variant | Device | CPU Latency | GPU Latency |
97
+ |---|---|---:|---:|
98
+ | Average Word Embedding | Pixel 6 | 0.14 ms | — |
99
+
100
+ ## Intended Use, Limitations, and Fairness
101
+
102
+ - **Intended applications:** Binary English sentiment analysis (positive vs. negative) on short text snippets such as reviews and feedback.
103
+ - **Out-of-scope & limitations:**
104
+ - **English only:** Not suitable for non-English text.
105
+ - **Domain shift:** Trained on SST-2 movie reviews (`https://nlp.stanford.edu/sentiment/index.html`); accuracy may degrade on unrelated domains, sarcasm, or multi-sentence documents.
106
+ - No standalone Google fairness PDF is published for this model on the MediaPipe documentation page.
107
+
108
+ ## Provenance
109
+
110
+ 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`.
111
+
112
+ | Repo File | Upstream URL | GCS Generation | Upstream `Last-Modified` | Pinned Bucket Version |
113
+ |---|---|---|---|---|
114
+ | `average_word_classifier.tflite` | [`average_word_classifier.tflite`](https://storage.googleapis.com/mediapipe-models/text_classifier/average_word_classifier/float32/latest/average_word_classifier.tflite) | `1682480023219908` | Wed, 26 Apr 2023 03:33:43 GMT | `/1/` |
115
+
116
+ ## License and Citation
117
+
118
+ - License: `apache-2.0` — Distributed under Apache License, Version 2.0 alongside the [MediaPipe](https://github.com/google-ai-edge/mediapipe) release artifacts.
average_word_classifier.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13bf6f7f35964f1e85d6cc762ee7b1952009b532b233baa5bdb4bf7441097f34
3
+ size 775706