Instructions to use litert-community/YOLACT-ResNet50-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/YOLACT-ResNet50-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
|
@@ -56,7 +56,30 @@ raw outputs) with **one patch**: the ResNet50 stem `MaxPool2d(padding=1)` lowers
|
|
| 56 |
post-ReLU). The scripted FPN is made traceable by disabling YOLACT's JIT
|
| 57 |
(`use_jit=False`). CPU-exact vs PyTorch (corr 1.0).
|
| 58 |
|
| 59 |
-
## Minimal usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
```python
|
| 62 |
import numpy as np
|
|
@@ -77,8 +100,6 @@ boxes = np.concatenate([cxy - wh / 2, cxy + wh / 2], 1) # x1y1x2y2 (0..1)
|
|
| 77 |
# then per-class NMS on conf, and mask_i = sigmoid(proto @ mask[i]) cropped to boxes[i]
|
| 78 |
```
|
| 79 |
|
| 80 |
-
A full Android decode is in the sample app (`YolactSegmenter.kt`).
|
| 81 |
-
|
| 82 |
## License
|
| 83 |
|
| 84 |
MIT (YOLACT / dbolya/yolact). COCO class taxonomy.
|
|
|
|
| 56 |
post-ReLU). The scripted FPN is made traceable by disabling YOLACT's JIT
|
| 57 |
(`use_jit=False`). CPU-exact vs PyTorch (corr 1.0).
|
| 58 |
|
| 59 |
+
## Minimal usage
|
| 60 |
+
|
| 61 |
+
### Kotlin (Android, LiteRT CompiledModel GPU)
|
| 62 |
+
|
| 63 |
+
```kotlin
|
| 64 |
+
val options = CompiledModel.Options(Accelerator.GPU)
|
| 65 |
+
val model = CompiledModel.create(context.assets, "yolact.tflite", options, null)
|
| 66 |
+
val inBufs = model.createInputBuffers()
|
| 67 |
+
val outBufs = model.createOutputBuffers() // map by size: loc=N*4, conf=N*81, mask=N*32, proto=138*138*32
|
| 68 |
+
|
| 69 |
+
inBufs[0].writeFloat(inputNCHW) // [1,3,550,550] BGR, (x-[103.94,116.78,123.68])/[57.38,57.12,58.40]
|
| 70 |
+
model.run(inBufs, outBufs)
|
| 71 |
+
val loc = outBufs[iLoc].readFloat() // [19248*4]
|
| 72 |
+
val conf = outBufs[iConf].readFloat() // [19248*81] (softmax)
|
| 73 |
+
val mask = outBufs[iMask].readFloat() // [19248*32] coefficients
|
| 74 |
+
val proto = outBufs[iProto].readFloat() // [138*138*32] prototypes
|
| 75 |
+
|
| 76 |
+
// host-side decode (priors.bin bundled as an asset):
|
| 77 |
+
// box = SSD-decode(loc, priors, variances=[0.1,0.2]); per-class NMS (score 0.3, IoU 0.5);
|
| 78 |
+
// per kept det: mask = sigmoid(proto @ coeff) (>0) cropped to the box.
|
| 79 |
+
// Full implementation: YolactSegmenter.kt in the sample app.
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
### Python (LiteRT / ai-edge-litert)
|
| 83 |
|
| 84 |
```python
|
| 85 |
import numpy as np
|
|
|
|
| 100 |
# then per-class NMS on conf, and mask_i = sigmoid(proto @ mask[i]) cropped to boxes[i]
|
| 101 |
```
|
| 102 |
|
|
|
|
|
|
|
| 103 |
## License
|
| 104 |
|
| 105 |
MIT (YOLACT / dbolya/yolact). COCO class taxonomy.
|