Skin retouching for the LiteRT GPU delegate

LiteRT conversions of the portrait skin retouching networks from damo/cv_unet_skin-retouching (ABPN, Alibaba DAMO Academy, Apache License 2.0), made for the Pixybay editor.

File Network Input Output .tflite SHA-256
skin-smooth-512-gpu.tflite.gz UNet generator (13.4 M) [1, 512, 512, 3] RGB 0–1 [1, 512, 512, 3] blend layer 0–1 c50b14b594f5136bccbf35ff11ea20c075f681ad4d088ecbc24466cdab52b043
skin-blemish-768-gpu.tflite.gz DetectionUNet (18.0 M) [1, 768, 768, 3] RGB 0–1 [1, 768, 768, 1] blemish probability 8dce541ec9c75fec40e85433832b4c781b9b7d7f23dfcbc93635bd222fdccfc5

Both graphs are NHWC float32 and use only CONV_2D, CONCATENATION, MAX_POOL_2D, RESIZE_*, PAD, LEAKY_RELU, LOGISTIC, MUL and SUB, so the whole graph runs on the GPU delegate.

Use

Smoothing, on a face crop resized to 512 Γ— 512:

mg' = (mg - 0.5) * degree + 0.5
out = (1 - 2 mg') * imgΒ² + 2 mg' * img

Blemishes: threshold the probability at 0.35 (soft between 0.35 and 0.5, hard above), and fill the mask with any inpainting model. The original inpainting network and the skin segmentation graph are not included.

Changes from the original

  • Exported PyTorch β†’ ONNX β†’ LiteRT (onnx2tf 2.6.9). The [-1, 1] input normalisation and the detector's sigmoid are inside the graphs; the zero-size F.pad in the UNet decoder is removed (sizes always match at 512 Γ— 512).
  • Weights are stored as FP32 but rounded to FP16 precision (the GPU delegate rejects DEQUANTIZE and computes in FP16 anyway), which roughly halves the gzip size. Against PyTorch FP32: 86 dB PSNR, max abs difference 0.0014. See skin-retouch-report.json.

The original model card asks for faces larger than 100 Γ— 100 px. Licensed under Apache 2.0, see LICENSE; copyright of the original weights belongs to Alibaba, Inc. and its affiliates.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support