Skip to content

Repository files navigation

FaceSlim

VersionLicensePythonPlatformStatus

AI-powered face slimming, reshaping, and beautification suite with real-time preview, GPU acceleration, and CLI batch processing.

Quick Start

git clone https://github.com/SysAdminDoc/FaceSlim.git
cd FaceSlim
python tools/bootstrap_dev.py
.venv\Scripts\python FaceSlim_v1.py

On first launch, FaceSlim downloads the face landmarker (~3.7 MB), the selected BiSeNet parsing model (~50-94 MB), and MODNet (~25 MB) only when matting refinement is enabled. Python dependencies are installed through requirements.txt.

Features

Face Reshaping (Warp-Based)

FeatureDescriptionMethod
Jaw SlimmingNarrows the jawlineTPS warp toward face center
Cheek SlimmingReduces cheek fullnessTPS warp toward face center
Chin ReshapeLifts and narrows the chinTPS warp with vertical bias
Overall WidthReduces overall face widthFull jaw contour inward warp
Forehead SlimNarrows the foreheadTPS warp on forehead landmarks
Nose SlimNarrows the nose bridge and tipHorizontal-only warp toward nose centerline
Eye EnlargeEnlarges eyes from iris centerRadial outward push on eye contour
Lip PlumpPlumps lips outwardDirectional push (upper=up, lower=down) + radial
Expression NeutralizeSoftens frowns and raised/lowered browsMediaPipe blendshape-guided local warp

AI Beauty (BiSeNet Parsing-Based)

FeatureDescriptionMethod
Skin SmoothingSmooths skin while preserving textureFrequency-separation bilateral filter on skin-only mask
Skin Tone EvenReduces redness and blotchinessLAB color correction + mean-color blending
Teeth WhiteningBrightens teeth naturallyHSV saturation/brightness on mouth interior only
Teeth Target MaskShows the exact whitening target in previewVisual-only BiSeNet mouth-interior overlay
Eye SharpenSharpens iris and brow detailUnsharp mask on eye/brow parsing region
Lip ColorBoosts lip saturation and warmthHSV saturation boost on lip parsing region
Under-Eye SmoothSmooths the infraorbital region separatelyLandmark-guided under-eye mask + skin smoother
Hair ControlsHue, saturation, and density hintsBiSeNet hair-class masking
Makeup OverlaysBlush, lip gloss, and eye shadowProcedural opacity-controlled masks

Pipeline & Performance

FeatureDescription
BiSeNet Face Parsing19-class pixel-level segmentation via ONNX Runtime
Parser Model SelectorToggle BiSeNet ResNet18 or ResNet34 ONNX masks in Settings/CLI
MODNet Matting RefinementOptional portrait matte edge refinement for ROI warp masks
Background ProtectionROI-isolated warp + seamless clone composite
Runtime Provider SelectorPersisted ONNX Runtime Auto/CPU/CUDA/DirectML override with diagnostics and one-frame benchmark
Model Provenance InventoryGUI/CLI source, license, hash, cache, provider, and redownload status for every model
Temporal Mask SmoothingEMA filter prevents parsing mask flicker on video
Optical Flow PropagationWarp displacement propagation between TPS keyframes
GPU AccelerationPyTorch TPS warping on CUDA (auto-detected)
DirectML Face ParsingONNX Runtime DirectML provider on Windows when available
Multi-Face SupportUp to 5 simultaneous faces with per-face caching
Per-Face OverridesCLI/manifest can apply different presets or values per face index
Real-Time PreviewWebcam/video with live slider adjustment
Video Timeline ScrubberPer-second seeking with current slider-state preview
OBS Virtual CameraStream the processed preview to an OBS-compatible virtual webcam
A/B CompareDraggable split-screen before/after overlay
Batch ProcessingFolder/multi-file image and video processing
Batch ManifestJSON jobs with per-file preset, face overrides, output, watermark, and compare settings
Batch Queue DialogPer-file status, progress, ETA, and single-job cancellation
Large-Media PreflightChecks resolution, frame count, estimates, disk space, output writability, and MP4 codec support before long renders
Optional Restore/Upscale Post-StageGFPGAN face restoration and Real-ESRGAN 2x upscale with identity fidelity, strength, tiling, and compare/export parity
CLI ModeHeadless with presets and per-param control
Docker CLI ImageHeadless container build for farm rendering
Compatibility Upgrade LaneLocal Python 3.12+ dependency canary with current PyPI comparison
Metadata PreservationImage exports preserve source EXIF/ICC metadata by default and embed FaceSlim provenance
Disclosure WatermarkOptional exported media badge declaring AI modification
Responsible-Use GateFirst-launch acknowledgement for consent, disclosure, and platform-rule expectations
Accessibility MetadataScreen-reader names/descriptions, explicit tab order, and contrast QA coverage
Localization-Ready UIMain UI/CLI strings route through translation helpers with pseudo-locale overflow tests
Modular Package LayoutModel management, pipeline, exporters, UI, and CLI entry points live under faceslim/
Preset System9 built-in + unlimited custom presets (JSON)
Before/After GIFOne-click animated comparison export
Drag & DropDrop images/videos directly onto the window
Undo/Redo50-level parameter history
Settings PersistenceSlider values saved between sessions

How It Works

┌──────────────┐ ┌───────────────┐ ┌───────────────┐ ┌──────────────┐
│ Input Frame │───>│ MediaPipe │───>│ TPS Warp │───>│ Post-Warp │
│ (RGB) │ │ 478 Landmarks │ │ (GPU/CPU) │ │ Effects │
│ │ │ + One-Euro │ │ ROI-isolated │ │ │
│ │ │ filtering │ │ + Seamless │ │ BiSeNet │
│ │ │ │ │ Clone │ │ Parsing │
└──────────────┘ └───────────────┘ └───────────────┘ └──────┬───────┘
┌───────────────┐ ┌───────────────┐ │
│ Output Frame │<───│ Skin Smooth │<──────────┘
│ (RGB) │ │ Tone Even │
│ │ │ Teeth Whiten │
│ │ │ Eye Sharpen │
│ │ │ Lip Color │
└───────────────┘ └───────────────┘
Video Mode Only:
┌──────────────────────────────────────────────┐
│ Optical Flow Propagator │
│ Keyframe (every 4 frames) → full TPS solve │
│ Interim frames → Farneback flow warp of │
│ cached displacement field │
└──────────────────────────────────────────────┘

Usage

GUI Mode

python FaceSlim_v1.py

The interface has three tabs: Reshape (sliders for all effects plus preview overlays), Presets (built-in/custom preset management), and Export (video export, screenshots, batch, GIF). File videos expose a per-second timeline scrubber under the preview.

CLI Mode

# Single image with preset
python FaceSlim_v1.py --input photo.jpg --preset Moderate
# AI beauty only
python FaceSlim_v1.py --input photo.jpg --preset Beauty
# Full glamour (reshaping + beauty)
python FaceSlim_v1.py --input photo.jpg --preset Glamour
# Custom parameters
python FaceSlim_v1.py --input video.mp4 --jaw 50 --eye-enlarge 30 --lip-plump 20 --skin-smooth 40
# Batch folder processing
python FaceSlim_v1.py --input ./photos/ --output ./results/ --preset Strong
# GUI batch processing# Export tab -> Select Files for Batch / Process Entire Folder / Run Manifest opens the queue dialog# Multi-face processing
python FaceSlim_v1.py --input group.jpg --faces 3 --preset "Full Sculpt"# Per-face overrides
python FaceSlim_v1.py --input group.jpg --faces 3 --face-preset 1=Subtle --face-param 2:jaw=45
# Batch manifest with per-file settings
python FaceSlim_v1.py --manifest batch.json --output ./results/
# Split-screen video export with disclosure watermark
python FaceSlim_v1.py --input video.mp4 --preset Glamour --video-compare split --watermark
# Higher-quality parser model
python FaceSlim_v1.py --input photo.jpg --parser-model bisenet_resnet34 --skin-smooth 35
# Force CPU ONNX inference or inspect available providers
python FaceSlim_v1.py --input photo.jpg --onnx-provider cpu --skin-smooth 35
python FaceSlim_v1.py --provider-diagnostics --onnx-provider auto
# Inspect or refresh model artifacts
python FaceSlim_v1.py --list-models --onnx-provider cpu
python FaceSlim_v1.py --redownload-model bisenet_resnet18
# Cleaner face/background boundary on strong warps
python FaceSlim_v1.py --input photo.jpg --jaw 45 --matting-refine 70
# Optional face restoration and 2x upscale post-stage
python FaceSlim_v1.py --input photo.jpg --post-stage gfpgan_1.4 --post-strength 60 --post-fidelity 80
python FaceSlim_v1.py --input photo.jpg --post-stage gfpgan_1.4_real_esrgan_x2 --post-tile 512
# Blendshape-guided expression softening
python FaceSlim_v1.py --input photo.jpg --expression-neutralize 65
# List available presets
python FaceSlim_v1.py --list-presets
python FaceSlim_v1.py --locale pseudo --list-presets

CLI Arguments

ArgumentTypeDescription
--input, -ipath(s)Input image(s), video(s), or folder(s)
--output, -opathOutput directory (default: faceslim_output/)
--preset, -pstringNamed preset (built-in or custom)
--jaw0-100Jawline slimming
--cheeks0-100Cheek slimming
--chin0-100Chin reshaping
--face-width0-100Face width reduction
--forehead0-100Forehead narrowing
--nose0-100Nose slimming
--eye-enlarge0-100Eye enlargement
--lip-plump0-100Lip plumping
--expression-neutralize0-100Blendshape-guided frown and brow dampening
--skin-smooth0-100AI skin smoothing
--skin-tone-even0-100AI skin tone evening
--teeth-whiten0-100AI teeth whitening
--eye-sharpen0-100AI eye sharpening
--lip-color0-100AI lip color enhancement
--under-eye0-100Dedicated under-eye smoothing
--hair-hue0-100Hair hue shift
--hair-saturation0-100Hair saturation boost
--hair-density0-100Hair density hint
--blush0-100Procedural blush overlay
--lip-gloss0-100Lip gloss overlay
--eye-shadow0-100Eye shadow overlay
--smoothing10-100Warp field smoothness
--temporal0-100Temporal landmark smoothing
--bg-protect0-100Background protection
--matting-refine0-100MODNet mask edge refinement
--post-stageoff, gfpgan_1.4, real_esrgan_x2, gfpgan_1.4_real_esrgan_x2Optional post-stage face restoration/upscale model
--post-strength0-100Blend amount for the post-stage
--post-fidelity0-100Identity-preserving blend control; higher keeps more original face detail
--post-tilepixelsReal-ESRGAN tile size for large images/video frames
--faces1-5Max faces to process
--face-presetFACE=PRESETApply a preset to one face index
--face-paramFACE:key=valueOverride one parameter for one face index
--manifestpathJSON batch manifest
--watermarkflagAdd AI modification disclosure watermark
--strip-metadataflagDo not preserve source image EXIF/XMP/ICC metadata
--video-comparenone, split, side_by_sideExport processed, split-screen, or side-by-side video
--parser-modelbisenet_resnet18, bisenet_resnet34Face parsing model for beauty masks
--onnx-providerauto, cpu, cuda, directmlONNX Runtime provider override
--provider-diagnosticsflagShow available providers, selected/fallback provider, and one-frame benchmark
--list-modelsflagShow model source, license, hash, cache, provider, and verification status
--redownload-modelmodel key or allDelete and re-download a model artifact with hash verification
--localeen, pseudo, qpsOverride UI/CLI locale; pseudo modes are for layout QA
--list-presetsflagList all available presets

Batch Manifest

{
"preset": "Moderate",
"parser_model": "bisenet_resnet34",
"faces": 3,
"watermark": true,
"video_compare": "split",
"files": [
{
"input": "photos/group.jpg",
"params": {"skin_smooth": 35},
"face_params": {"2": {"jaw": 45, "cheeks": 20}}
},
{
"input": "clips/demo.mp4",
"preset": "Glamour",
"output": "results/demo_split.mp4"
}
]
}

Built-In Presets

PresetFocusKey Parameters
SubtleLight face slimmingjaw=15, cheeks=10
ModerateBalanced slimmingjaw=35, cheeks=25, chin=15
StrongAggressive slimmingjaw=60, cheeks=45, chin=30
V-ShapeJaw-focused sculptingjaw=70, chin=40
OvalRounded face shapejaw=40, cheeks=35, face_width=30
Slim NoseNose onlynose=50
Full SculptAll reshaping combinedjaw=50, cheeks=40, nose=30
BeautyAI beautification onlyskin_smooth=40, teeth=20, eyes=30, lips=20
GlamourFull reshaping + beautificationAll effects combined

Configuration

Custom presets are stored as JSON in:

OSLocation
Windows%APPDATA%\.faceslim\presets\
macOS/Linux~/.faceslim/presets/

Slider values persist between sessions via Qt settings. Crash logs are written to crash.log; render/export diagnostics are written as JSON lines to render.log in the application directory. The first GUI launch shows a responsible-use acknowledgement and stores it in Qt settings after acceptance. English is the default locale. Set FACESLIM_LOCALE=pseudo or pass --locale pseudo for pseudo-localized CLI/UI QA; pseudo strings are covered by overflow guardrail tests for the main controls.

Video exports, batch jobs, and CLI processing run a preflight before long renders start. The preflight reports input resolution, frame count or duration, estimated output size, estimated memory and render time, free disk space, output writability, and MP4 writer availability. Jobs with missing input, unsupported media, blocked output paths, unavailable codec support, or insufficient disk are refused with a render.log diagnostic entry.

Runtime Providers

FaceSlim can run ONNX face parsing and matting models through Auto, CPU, CUDA, or DirectML. The GUI provider selector persists in Qt settings and the CLI can override it with --onnx-provider. If the requested provider is unavailable or fails to initialize for a model, FaceSlim falls back to CPUExecutionProvider and reports the fallback reason. Use the GUI Benchmark button or --provider-diagnostics to list available providers, the selected provider for BiSeNet and MODNet, and a one-frame benchmark.

Provenance Metadata

Image exports always embed FaceSlim provenance metadata. PNG outputs include XMP and text fields, and JPEG/TIFF/WebP outputs include EXIF provenance; JPEG outputs also get an APP1 XMP packet. The metadata records FaceSlim version, edit timestamp, IPTC DigitalSourceType algorithmicallyEnhanced, source metadata preservation status, and whether the visual disclosure watermark was enabled. --strip-metadata removes source metadata from the output but keeps FaceSlim provenance.

Models (Auto-Downloaded)

Model keyFileExpected sizeSHA-256 prefixSource / licensePurpose
face_landmarkerface_landmarker.task3,758,596 bytes64184e229b26Google MediaPipe, Apache-2.0478-point face landmarks
bisenet_resnet18bisenet_face_parsing.onnx53,205,364 bytes0d9bd318e469yakhyo/face-parsing, MITFast 19-class face segmentation (CelebAMask-HQ)
bisenet_resnet34bisenet_resnet34.onnx93,632,554 bytes5b805bba7b56yakhyo/face-parsing, MITHigher-quality 19-class face segmentation (CelebAMask-HQ)
modnet_photographicmodnet_photographic.onnx25,969,398 bytes5069a5e306b9yakhyo/modnet, Apache-2.0Optional portrait matte for ROI edge refinement
gfpgan_1.4gfpgan_1.4.onnx340,299,087 bytesaccc4757b26bTencentARC/GFPGAN, Apache-2.0Optional face restoration post-stage
real_esrgan_x2real_esrgan_x2.onnx69,552,244 bytes5be2d62ab3b0xinntao/Real-ESRGAN, BSD-3-ClauseOptional 2x upscale post-stage

The face landmarker and selected parser model are downloaded automatically on first use. Each cached or downloaded model must match the versioned in-app manifest by exact byte size and SHA-256 before it is used; corrupt caches are deleted and downloaded again through an atomic temporary file. Source-tree runs use model files beside FaceSlim_v1.py; packaged Windows builds cache models in %APPDATA%\.faceslim\models so downloads persist across launches. MODNet downloads only when matting refinement is enabled. If the selected BiSeNet model fails to download or verify, the app falls back to landmark-based polygon masking (reshaping still works, AI beauty effects are disabled). GFPGAN and Real-ESRGAN download only when the optional post-stage is enabled or explicitly redownloaded. GFPGAN is blended through face masks with the Identity Fidelity control to reduce identity drift; Real-ESRGAN runs tiled inference for large frames and can double the final image/video dimensions. Use the GUI model inventory controls or --list-models to inspect each model's source URL, license URL, cache path, active provider, and verification status. Use --redownload-model <key> or the GUI redownload action to refresh an artifact.

Requirements

  • Python 3.9+
  • One-command setup:python tools/bootstrap_dev.py
  • Manual install:python -m venv .venv && .venv\Scripts\python -m pip install -r requirements.txt
  • Optional: PyTorch + CUDA for GPU acceleration (auto-detected)
  • Optional: FFmpeg for audio muxing on video exports
  • Optional: OBS Virtual Camera driver for the Virtual Cam preview output

Build

python -m pip install -r requirements.txt
pyinstaller FaceSlim.spec --noconfirm --clean

If .venv was copied from another machine or points at a stale base interpreter, run python tools/bootstrap_dev.py; it recreates the venv when needed, installs requirements, compiles the launchers, and runs --list-presets.

Run the local regression suite with:

python -m unittest discover -s tests

Run the dependency upgrade lane with:

python tools/check_compatibility.py --online
py -3.12 tools/check_compatibility.py --canary --python-version 3.12 --requirements requirements-docker.txt
py -3.12 tools/check_compatibility.py --canary --python-version 3.12 --allow-blocked

Compatibility matrix:

LaneStatusNotes
Python 3.11Release/build hostNormal local tests and PyInstaller build run here.
Python 3.12Upgrade lanerequirements-docker.txt resolves on 3.12; requirements-upgrade-canary.txt verifies latest MediaPipe, NumPy, SciPy, Pillow, OpenCV, and the newest ONNX Runtime import canary that passes locally before pins move.
Python 3.13WatchDo not claim support until MediaPipe, PyQt, ONNX Runtime, and PyInstaller smokes pass.
Python 3.14ExperimentalInterpreter exists locally, but package ABI coverage and release behavior are still moving.

Current blockers before bumping runtime pins: ONNX Runtime 1.27.0 fails the Python 3.12 import smoke on this machine with a DLL initialization error, full GUI/PyInstaller smoke must pass on the canary set, and MediaPipe task behavior must be checked against the current face landmarker API after the dependency upgrade.

The Windows executable is emitted at dist/FaceSlim.exe. The spec includes a multiprocessing freeze guard to prevent frozen MediaPipe/OpenCV worker relaunch loops.

Docker CLI

docker build -t faceslim-cli .
docker run --rm -v "%cd%:/data" faceslim-cli --input /data/photo.jpg --output /data/faceslim_output --preset Moderate

The container uses requirements-docker.txt, opencv-python-headless, and QT_QPA_PLATFORM=offscreen for CLI-only rendering.

Supported Formats

TypeExtensions
Images.jpg.jpeg.png.bmp.tiff.tif.webp
Videos.mp4.avi.mov.mkv.webm.wmv.flv.m4v

FAQ / Troubleshooting

BiSeNet model fails to download The app falls back to landmark-based masking automatically. AI beauty effects (skin smooth, teeth whiten, etc.) require a BiSeNet model. You can manually download resnet18.onnx or resnet34.onnx from the face-parsing releases and place it in the app directory as bisenet_face_parsing.onnx or bisenet_resnet34.onnx.

Low FPS in real-time preview Use the Preview Scale dropdown (75% or 50%) in the Quality group. Install PyTorch with CUDA for GPU acceleration. Optical flow propagation kicks in automatically for video, computing full TPS only every 4th frame.

Warp affects the background Increase the Background Protection slider. At 70+ (default), warping is confined to the face ROI and blended back with seamless clone.

Face/background boundary looks soft on a strong warp Increase the Matting Refine slider. FaceSlim downloads MODNet on first use and multiplies the ROI blend mask by a portrait matte to reduce background bleed.

Video export has no audio Install FFmpeg and make sure it's on your PATH. FaceSlim automatically muxes audio from the original file when FFmpeg is available.

Faces not detected Ensure the face is reasonably front-facing and well-lit. MediaPipe requires a minimum face size — try loading a higher resolution source. For multi-face scenes, increase Max Faces (up to 5).

Crash on startup Check crash.log in the application directory. Common causes: incompatible Python version (<3.9), missing system libraries for PyQt5 on Linux (install libxcb-xinerama0), or corrupted model files (delete .task/.onnx files and relaunch to re-download).

Export or audio mux fails Check render.log in the application directory. FaceSlim keeps the rendered video if FFmpeg audio muxing fails and reports non-zero from CLI runs when any requested job fails.

License

MIT License. See LICENSE for details. Issues and PRs welcome.

About

AI-powered face slimming, reshaping, and beautification suite with real-time preview, GPU acceleration, and CLI batch processing.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages