Instructions to use litert-community/lightweight-openpose with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/lightweight-openpose 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
Add minimal usage snippets (Kotlin + Python)
Browse files
README.md
CHANGED
|
@@ -59,18 +59,39 @@ GREATER_EQUAL x6, SELECT x6, ADD x6, PAD x3, CONCATENATION x1
|
|
| 59 |
The fp16 model compiles to **158 / 158 nodes on the LiteRT GPU delegate (LITERT_CL)** — full
|
| 60 |
GPU residency, no CPU fallback.
|
| 61 |
|
| 62 |
-
##
|
|
|
|
|
|
|
| 63 |
|
| 64 |
```kotlin
|
| 65 |
-
val model = CompiledModel.create(
|
| 66 |
-
|
| 67 |
-
CompiledModel.Options(Accelerator.GPU), null
|
| 68 |
-
)
|
| 69 |
val inputs = model.createInputBuffers()
|
| 70 |
val outputs = model.createOutputBuffers()
|
| 71 |
-
inputs[0].writeFloat(
|
| 72 |
model.run(inputs, outputs)
|
| 73 |
-
val heatmaps = outputs[0].readFloat() // [1,32,32,19] -> argmax per keypoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
```
|
| 75 |
|
| 76 |
A complete Android sample (camera + gallery, skeleton overlay) is available in
|
|
|
|
| 59 |
The fp16 model compiles to **158 / 158 nodes on the LiteRT GPU delegate (LITERT_CL)** — full
|
| 60 |
GPU residency, no CPU fallback.
|
| 61 |
|
| 62 |
+
## Minimal usage
|
| 63 |
+
|
| 64 |
+
**Android (Kotlin, CompiledModel GPU)**
|
| 65 |
|
| 66 |
```kotlin
|
| 67 |
+
val model = CompiledModel.create(context.assets, "pose_256_fp16.tflite",
|
| 68 |
+
CompiledModel.Options(Accelerator.GPU), null)
|
|
|
|
|
|
|
| 69 |
val inputs = model.createInputBuffers()
|
| 70 |
val outputs = model.createOutputBuffers()
|
| 71 |
+
inputs[0].writeFloat(nhwc) // [1,256,256,3] RGB, (px - 128) / 256
|
| 72 |
model.run(inputs, outputs)
|
| 73 |
+
val heatmaps = outputs[0].readFloat() // [1,32,32,19] -> argmax per keypoint channel
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
**Python (desktop verification)**
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
import numpy as np
|
| 80 |
+
from PIL import Image
|
| 81 |
+
from ai_edge_litert.interpreter import Interpreter
|
| 82 |
+
|
| 83 |
+
img = Image.open("person.jpg").convert("RGB").resize((256, 256))
|
| 84 |
+
x = ((np.asarray(img, np.float32) - 128.0) / 256.0)[None] # [1,256,256,3] NHWC
|
| 85 |
+
|
| 86 |
+
it = Interpreter(model_path="pose_256_fp16.tflite"); it.allocate_tensors()
|
| 87 |
+
it.set_tensor(it.get_input_details()[0]["index"], x); it.invoke()
|
| 88 |
+
hm = it.get_tensor(it.get_output_details()[0]["index"])[0] # [32,32,19]
|
| 89 |
+
|
| 90 |
+
NAMES = ["nose","neck","r_sho","r_elb","r_wri","l_sho","l_elb","l_wri",
|
| 91 |
+
"r_hip","r_knee","r_ank","l_hip","l_knee","l_ank","r_eye","l_eye","r_ear","l_ear"]
|
| 92 |
+
for k, name in enumerate(NAMES): # channel 18 = background
|
| 93 |
+
gy, gx = divmod(hm[:, :, k].argmax(), 32)
|
| 94 |
+
print(f"{name}: ({gx/32:.2f}, {gy/32:.2f}) conf {hm[gy, gx, k]:.2f}")
|
| 95 |
```
|
| 96 |
|
| 97 |
A complete Android sample (camera + gallery, skeleton overlay) is available in
|