/ Модель

Характеристики

Размер весов
176 МБ
Лицензия
Apache 2.0
Библиотека
litert
Опубликована
7 июл 2026

U2Net-Portrait-Sketch-LiteRT

Преобразование изображенийИзображение, текст → изображение3 профессии

LiteRT-порт U²-Net преобразует фотографию лица в карту карандашного линейного портрета для локальных творческих фильтров.

340скачиваний за 30 дней1лайквеса обновлены8 сен 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

litert-community выпустила LiteRT-версию модели U²-Net Portrait для преобразования фотографии лица в карту карандашного линейного рисунка. Модель построена на сверточной архитектуре U²-Net с блоками RSU, принимает RGB-изображение размером 512×512 и выдаёт одноканальную карту 512×512; для получения тёмных штрихов на белом фоне результат нормализуют и инвертируют. Размер файлов модели — 176 МБ, формат — TFLite, библиотека запуска — LiteRT.

Модель предназначена для создания портретных скетчей и творческих или AR-фильтров на мобильных устройствах и других локальных устройствах. README сообщает о запуске на GPU через LiteRT CompiledModel без отката на CPU, а также приводит сценарии для Android и браузера. Качество лучше для центрированного лица; CPU-инференс может быть медленным и требовательным к памяти. Репозиторий распространяется по лицензии Apache-2.0.

Сценарии применения

  • создание карандашного скетча по фотографии лица
  • добавление портретного фильтра в Android-приложение
  • создание AR-эффекта линейного рисунка на устройстве
  • генерация контурного портрета для творческой обработки фото

Ограничения

Лучше работает с центрированным лицом. На CPU инференс медленный и может требовать значительного объёма памяти; для штрихов на белом фоне выходную карту нужно нормализовать и инвертировать.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Measured on device (edge-compat): Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 2872 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 53.3 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/u2net-portrait-sketch/CARD.md

U²-Net Portrait — Photo → pencil line drawing (LiteRT GPU)

On-device portrait sketch generation running fully on the LiteRT CompiledModel GPU delegate (no CPU fallback). The U²-Net portrait model turns a face photo into a hand-drawn pencil line portrait — a fun creative / AR filter. ~12 ms/frame on a Pixel 8a.

  • Architecture: U²-Net (RSU / nested residual U-blocks) — pure CNN.
  • Weights: xuebinqin/U-2-Net (u2net_portrait) · Apache-2.0.
  • Size: 176 MB.

U2-Net portrait sketch

Input (left) → generated pencil portrait (right). Photo: Unsplash (free license).

I/O

  • Input: [1, 3, 512, 512] NCHW, RGB, x/max then ImageNet-normalized (mean [0.485,0.456,0.406], std [0.229,0.224,0.225]). A centered face works best.
  • Output: [1, 1, 512, 512] in [0,1]. Min-max normalize, then invert (1 − x) for dark strokes on white paper.

GPU conversion

U²-Net is a pure CNN → fully GPU-compatible (893/893 nodes on the delegate, 1 partition; device corr 0.998683, ~12 ms) with one defensive patch: align_corners=True → False on the bilinear upsamples. CPU-exact vs PyTorch (corr 1.0).

Minimal usage

Kotlin (Android, LiteRT CompiledModel GPU)

val options = CompiledModel.Options(Accelerator.GPU)
val model = CompiledModel.create(context.assets, "portrait.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers()

inBufs[0].writeFloat(inputNCHW)          // [1,3,512,512] RGB, /max then ImageNet-norm
model.run(inBufs, outBufs)
val d = outBufs[0].readFloat()           // [512*512] 0..1; min-max normalize then 1-x -> pencil sketch

Python (LiteRT / ai-edge-litert)

import numpy as np
from ai_edge_litert.interpreter import Interpreter

it = Interpreter(model_path="portrait.tflite"); it.allocate_tensors()
inp, out = it.get_input_details(), it.get_output_details()
it.set_tensor(inp[0]["index"], x)        # [1,3,512,512] float32, RGB, /max, ImageNet-norm
it.invoke()
d = it.get_tensor(out[0]["index"])[0, 0]
d = (d - d.min()) / (d.max() - d.min()); sketch = 1.0 - d   # dark strokes on white

Conversion

Converted with litert-torch (build_portrait.py): loads the Apache-2.0 u2net_portrait weights and exports the sketch map.

Performance

Measured on a Pixel 8a (Tensor G3, Android 16) with the standard TFLite benchmark_model tool — 10 warm-up runs then 50 timed runs, reported as the tool's mean.

RuntimeBackendGraph on GPULatency
LiteRT CompiledModel (LITERT_CL)GPU893 / 893~12 ms
TFLite benchmark_model (TfLiteGpuDelegateV2)GPU (OpenCL)255 / 255216.6 ms
TFLite benchmark_modelCPU (XNNPACK, 4 threads)—4196.3 ms

The two GPU rows are different runtimes, not a contradiction. The LITERT_CL figure is the one recorded when this model shipped, taken through LiteRT's own CompiledModel accelerator — the path the Kotlin sample app and the LiteRT API use. The TfLiteGpuDelegateV2 figure is the classic TFLite OpenCL delegate, measured with a tool anyone can download and re-run. They agree on how much of the graph the GPU takes; they disagree on speed, and the classic delegate is the slower of the two here. Read the TfLiteGpuDelegateV2 row as a reproducible floor, not as this model's speed on LiteRT.

Snapdragon NPU (Hexagon)

The NPU is 2.80x faster than the GPU (24.00 ms against 67.19 ms) and loads 7.31x faster (189 ms against 1381 ms).

backendinference (median / min)load
NPU (Hexagon v81)24.00 ms / 22.83 ms189 ms
GPU (Adreno)67.19 ms / 66.51 ms1381 ms

Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16), LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up runs then N=50 timed runs, median reported. Every run held thermal status NONE throughout. Headroom 0.77-0.79, where 1.0 is the throttling threshold.

The NPU rows here ran artifacts compiled ahead of time for SM8850 with QAIRT 2.47.0; the GPU rows ran the published files as they are. LiteRT can also compile for the NPU on the device at first load, which is what lets you ship the published file unchanged — that path and the ten runtime libraries it needs are in the NPU recipe, and we did not measure it here. GPU wiring is in the GPU recipe.

Raspberry Pi 5 (CPU)

Measured on a Raspberry Pi 5 Model B Rev 1.1 (8 GB, Raspberry Pi OS 64-bit) with the LiteRT benchmark_model tool from litert-cli-nightly 0.2.0.dev20260805: CPU inference (XNNPACK, 4 threads), 3 invocations per file of 10 warm-up plus 50 timed runs (the tool caps a phase at 150 s, so very slow graphs run fewer — the Runs column is the actual timed total). The latency is the median across invocations; the spread is the min–max over all timed runs. No thermal throttling occurred during these runs (vcgencmd get_throttled stayed 0x0).

FileInference (median)Spread (min–max)RunsPeak memory
portrait.tflite2,871.9 ms2,791.2–2,967.3 ms150968 MB

License

Apache-2.0 (U²-Net / xuebinqin).

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · litert

Нельзя запустить

Модели «картинка → картинка» пока не запускаются.

Ревизия весов
5c4f635

0 моделей