Add BiSeNet face parsing sample (CompiledModel GPU)#201
Open
john-rocky wants to merge 6 commits into
Open
Conversation
BiSeNet (zllrunning/face-parsing.PyTorch, MIT) — real-time 19-class CelebAMask-HQ face parsing (skin, brows, eyes, nose, lips, ears, hair, ...), running fully on the LiteRT CompiledModel GPU at ~22 ms/frame on a Pixel 8a. For AR / beauty / makeup. BiSeNet is a pure CNN (ResNet18 backbone). Three re-authoring patches make it a fully GPU-compatible graph (74/74 nodes on the delegate, 1 partition): align_corners=True->False; global avg_pool2d(x,x.size()[2:])->mean([2,3]) (Mali rejects a full-spatial-kernel AVERAGE_POOL_2D); ZeroPadMaxPool (the ResNet stem maxpool's -inf PADV2 is rejected as 'PADV2: src has wrong size', replaced by an explicit 0-pad + unpadded maxpool, exact post-ReLU). These are on-device-only rejections (op inventory clean, CPU parity 1.0). Device Mali GPU corr 0.99999, argmax 99.96%. Sample at compiled_model_api/face_parsing/bisenet_kotlin_gpu (android app + conversion scripts), with a deterministic bundled face demo.
eeb54a9 to
3e2a320
Compare
Merge hard-wrapped lines (paragraphs, list items, blockquotes) into single lines so the markdown renders as normal prose. Tables, code blocks, and content are unchanged.
… conversion script, document all three GPU patches, copyright 2026
Wrap every line in the conversion scripts to the 80-column limit of the Google Python Style Guide and add Args/Returns sections to the module-level function docstrings. No behavior changes.
Restructure the app to the image_segmentation reference: a thin ComponentActivity host over a MainViewModel + immutable UiState, UI strings moved to res/values, a Gradle version catalog, and status-bar inset padding. Inference/model code is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BiSeNet (zllrunning/face-parsing.PyTorch, MIT) — real-time 19-class CelebAMask-HQ face parsing (skin, brows, eyes, nose, lips, ears, hair, hat, glasses, neck, cloth, …), running fully on the LiteRT
CompiledModelGPU at ~22 ms/frame on a Pixel 8a. For AR / beauty / makeup. Fills the face-parsing gap in the samples.BiSeNet is a pure CNN (ResNet18 backbone + context path + feature fusion). Three re-authoring patches make it a fully GPU-compatible graph — 74/74 nodes on the delegate, 1 partition (device corr 0.99999, argmax 99.96% vs PyTorch):
align_corners=True→False— the output upsamples usealign_corners=True, which the GPU delegate rejects.avg_pool2d(x, x.size()[2:])→mean([2,3])— full-spatial-kernel pooling is rejected by the Mali delegate asAVERAGE_POOL_2D; a MEAN reduce is supported.MaxPool2d(padding=1)lowers to a-infPADV2 (PADV2: src has wrong sizeon Mali); an explicit 0-pad + unpadded maxpool is exact (post-ReLU input ≥ 0).These are on-device-only rejections (the op inventory is clean and CPU parity is 1.0). CPU-exact vs PyTorch (corr 0.99999999999).
Model: litert-community/BiSeNet-Face-Parsing-LiteRT (53 MB).
Sample at
compiled_model_api/face_parsing/bisenet_kotlin_gpu(android app + conversion scripts), with a deterministic bundled face demo.