Video Classification
LiteRT
LiteRT
android
on-device
gpu
video-action-recognition
kinetics-600
movinet
streaming
Instructions to use litert-community/MoViNet-A0-Stream-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/MoViNet-A0-Stream-LiteRT 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
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -93,8 +93,30 @@ for n, frame in enumerate(video_frames, start=1): # frame: [1,3,172,172], RGB,
|
|
| 93 |
print("top-1:", int(logits.argmax()))
|
| 94 |
```
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
## Conversion
|
| 100 |
|
|
|
|
| 93 |
print("top-1:", int(logits.argmax()))
|
| 94 |
```
|
| 95 |
|
| 96 |
+
### Kotlin (Android, LiteRT CompiledModel GPU)
|
| 97 |
+
|
| 98 |
+
```kotlin
|
| 99 |
+
val options = CompiledModel.Options(Accelerator.GPU)
|
| 100 |
+
val model = CompiledModel.create(context.assets, "movinet_a0_stream.tflite", options, null)
|
| 101 |
+
val inBufs = model.createInputBuffers() // [0]=frame, [1..28]=stream, [29..44]=pool sums, [45]=inv_count, [46]=1.0
|
| 102 |
+
val outBufs = model.createOutputBuffers() // [0]=logits, [1..11]=current frames, [12..27]=fresh means
|
| 103 |
+
|
| 104 |
+
inBufs[46].writeFloat(floatArrayOf(1f)) // constant decoupler
|
| 105 |
+
// reset recurrent state (zeros) at the start of a clip; keep host-side stream buffers + pool sums
|
| 106 |
+
|
| 107 |
+
for ((n, frameNCHW) in videoFrames.withIndex()) { // frame: [1,3,172,172], RGB, 0..1
|
| 108 |
+
inBufs[0].writeFloat(frameNCHW)
|
| 109 |
+
inBufs[45].writeFloat(floatArrayOf(1f / (n + 1))) // inv_count
|
| 110 |
+
// (stream inputs 1..28 and pool inputs 29..44 already staged from the previous frame)
|
| 111 |
+
model.run(inBufs, outBufs)
|
| 112 |
+
val logits = outBufs[0].readFloat() // [600] Kinetics-600
|
| 113 |
+
// host-side: shift each stream buffer with the emitted current frame (outBufs[1..11]),
|
| 114 |
+
// and accumulate poolSum[i] += outBufs[12+i], then write both back to inBufs for the next frame.
|
| 115 |
+
}
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
A full implementation (camera → per-frame → top-5, with the host-side shift register and pool
|
| 119 |
+
accumulation) is in the sample app's `ActionRecognizer.kt`.
|
| 120 |
|
| 121 |
## Conversion
|
| 122 |
|