Add U2-Net Portrait photo-to-pencil-sketch sample (CompiledModel GPU)#217
Open
john-rocky wants to merge 5 commits into
Open
Add U2-Net Portrait photo-to-pencil-sketch sample (CompiledModel GPU)#217john-rocky wants to merge 5 commits into
john-rocky wants to merge 5 commits into
Conversation
The U2-Net portrait model (xuebinqin/U-2-Net, Apache-2.0) turns a face photo into a hand-drawn pencil line portrait — a fun creative / AR filter — running fully on the LiteRT CompiledModel GPU at ~12 ms/frame on a Pixel 8a. First portrait-sketch sample. Pure CNN (U2-Net RSU blocks) → fully GPU-compatible (893/893 nodes, 1 partition; device corr 0.998683) with one defensive patch: align_corners=False. CPU-exact vs PyTorch (corr 1.0). Input [1,3,512,512] RGB ImageNet-norm, output [1,1,512,512] (min-max normalize, invert for dark strokes on white). Sample at compiled_model_api/portrait_sketch/u2net_portrait_kotlin_gpu (android app + conversion scripts), with a deterministic bundled-image photo-to-sketch demo.
… conversion script, drop personal path default, 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.
john-rocky
force-pushed
the
u2net-portrait-sketch-sample
branch
from
July 9, 2026 03:09
817f888 to
1254017
Compare
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.
The U²-Net portrait model (Apache-2.0) turns a face photo into a hand-drawn pencil line portrait — a fun creative / AR filter — running fully on the LiteRT
CompiledModelGPU at ~12 ms/frame on a Pixel 8a. The first portrait-sketch sample.Pure CNN (U²-Net RSU blocks) → fully GPU-compatible (893/893 nodes on the delegate, 1 partition; device corr 0.998683) with one defensive patch:
align_corners=False. CPU-exact vs PyTorch (corr 1.0). Input[1,3,512,512]RGB ImageNet-norm, output[1,1,512,512](min-max normalize, invert for dark strokes on white).Model: litert-community/U2Net-Portrait-Sketch-LiteRT.
Sample at
compiled_model_api/portrait_sketch/u2net_portrait_kotlin_gpu(android app + conversion scripts), with a deterministic bundled-image photo-to-sketch demo.