Image-to-Image
LiteRT
LiteRT
LiteRT
on-device
android
gpu
style-transfer
neural-style
fast-neural-style
Instructions to use litert-community/Fast-Neural-Style-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/Fast-Neural-Style-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
Fast Neural Style Transfer β LiteRT (on-device, fully-GPU, 4 styles)
Fast neural style transfer (PyTorch examples
TransformerNet, Johnson et al.), converted to LiteRT and running fully on the CompiledModel GPU
(ML Drift) on Android. Applies an artistic style to a photo β 4 styles (candy / mosaic / rain_princess /
udnie), each a 3.5 MB fp16 graph.
On-device (Pixel 8a, Tensor G3 β verified)
| nodes on GPU | 350 / 350 LITERT_CL (full residency) |
| inference | ~9 ms (256Γ256) |
| size | 3.5 MB per style (fp16) |
| accuracy | device-vs-PyTorch corr 0.9998β0.9999 (all 4 styles) |
image[1,3,256,256] (RGB 0-255) β[GPU: TransformerNet]β stylized[1,3,256,256] (RGB 0-255)
How it converts (litert-torch) β three numerically-exact re-authorings
ReflectionPad2dβ zero-pad (GATHER_NDβPAD; border-only difference).- Large conv activations β conv-weight scaling. The conv outputs reach β |5000|, where the Mali delegate's
fp16 conv accumulation loses precision β garbage (device corr 0.34 at full residency β residency β
correctness). Each conv is followed by an
InstanceNorm(which is scale-invariant), so scaling those conv weights down so the output is β |10| is exact (IN output unchanged) and keeps the fp16 accumulation precise β corr 1.0. InstanceNormβ SafeInstanceNorm (down-scaled-domain spatial reduction, fp16-safe; SafeLayerNorm class).
Upsample is interpolate(nearest) (no transposed conv β no ZeroStuff). Result: banned ops NONE, β€4D,
tflite-vs-torch corr 1.0, device-vs-torch corr 0.9999.
Preprocessing
Center-crop to square, resize to 256Γ256, RGB 0β255 (no normalization), NCHW. Output is 0β255 RGB (clamp).
License
BSD-3-Clause. Upstream: pytorch/examples.
- Downloads last month
- -
