This project is an unofficial implementation of FabSoften: face beautification via dynamic skin smoothing, guided feathering, and texture restoration. Also this project is a python module written in C++.
- Make sure that you have all libs in /external (they are git submodules):
git submodule update --init --recursive
- Also you should install OpenCV (>= 4.8 — older ONNX importers cannot load the parsing model)
- Neural face-parsing weights (required — this is the face definition: the mask
boundary follows the real hairline/hat/glasses/neck). Download the MIT-licensed
BiSeNet weights into
assets/:
curl -L -o assets/face_parsing.onnx https://github.com/yakhyo/face-parsing/releases/download/weights/resnet18.onnx
mkdir build
cd build
cmake ..
cmake --build . -j
The C++ test suite (GoogleTest) is built by default. Run it from the build directory:
ctest
# or directly:
./tests/retouching_tests
Disable it with cmake .. -DRETOUCHING_BUILD_TESTS=OFF.
The native retouch binary runs the whole pipeline — no Python, no Docker. It is
built together with everything else (target retouch_cli) and lands right in the
repo root as ./retouch:
make # -> ./retouch (finds the build dir itself)
./retouch photo.jpg # -> photo_retouched.jpg
./retouch photo.jpg -o smooth.png --debug # custom output + masks in ./debug/
./retouch photo.jpg --strength 0.7 --max-radius 12 # gentler smoothing
./retouch --help # all options
Handy make shortcuts for the edit-build-try loop:
make run IMG=photo.jpg # rebuild + retouch with debug dumps
make run IMG=photo.jpg ARGS="--strength 0.7" # same, extra CLI options
make test # rebuild + run the C++ tests
(make auto-detects cmake-build-debug/build; override with BUILD_DIR=<dir>.
The explicit command is cmake --build <build-dir> --target retouch_cli.)
Every smoothing knob is exposed:
| Option | Default | Effect |
|---|---|---|
--strength <x> |
1.0 | ADF eps multiplier: <1 delicate, >1 harder |
--eps-cap <x> |
300 | cap for eps = 5·spots+100 (0 = uncapped) |
--max-radius <n> |
20 | largest smoothing window radius |
--texture-decay <x> |
0.5 | higher = more mid-frequency texture retained |
--no-spots |
off | disable blemish detection/inpainting |
--debug [dir] |
./debug | dump per-face skin mask, alpha matte, P_skin map, blemish mask, concealed/smoothed/restored frames |
The model is auto-searched (--model, $RETOUCH_PARSING_MODEL, ./face_parsing.onnx,
./assets/face_parsing.onnx, next to the binary).
If you prefer a container (on Linux prefix with sudo if needed):
docker build -t retouching-module .
docker run --rm -v "$PWD:/work" retouching-module photo.png
docker run --rm -e RETOUCH_DEBUG_DIR=/work/debug -v "$PWD:/work" retouching-module photo.png
(Only Windows issue for me, on Linux it works perfectly without this step) Put necessary dll's into the Release folder All necessary dll's you can find in assets or you can manually add it via building and compiling OpenCV
import smoothingmodule as sm
im = sm.RetouchingImg("Orig1.png", "face_parsing.onnx")- Preprocessing
- Face Detection (dlib HOG)
- Binary Skin Mask (neural face parsing, CelebAMask-HQ classes; hair/hat/glasses/neck/eyes/brows/lips excluded)
- Skin Mask Generation and Refinement
- GMM Clustering (Bayes posterior skin probability)
- Guided Feathering (soft alpha matte)
- Blemish Detection & Concealment (DoG → Canny → inpaint)
- Skin Imperfection Smoothing
- Dynamic Smoothing Hyperparameter (ADF: r = 10·P_skin + 10, eps = 5·num_spots + 100)
- Skin Texture Restoration (DWT)
| Name of the function | Discription | Input |
|---|---|---|
| Retouching | Retouching array-like data | Array-like data and Model Dir |
| RetouchingImg | Retouching photo (jpg, png, e.t.c.) | Photo Dir and Model Dir |






