mlboydaisuke commited on
Commit
a88ccaa
·
verified ·
1 Parent(s): e87473c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +24 -3
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 (Python, LiteRT / ai-edge-litert)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.