Skip to main content

Face morphing and alignment package using MediaPipe and OpenCV

Project description

Face Morphing

Smooth, fast, and robust, facemorph is a simple face morphing package that creates smooth transitions between faces. It uses Delaunay triangulation and piecewise affine warping. Optional face alignment ensures more natural results.

  • Landmarks: MediaPipe
  • Warping: OpenCV
  • Triangulation: SciPy
  • Math: NumPy

FaceMorph demo 1 FaceMorph demo 2

Install

pip install facemorph

Or from this repo:

git clone https://github.com/Robys01/Face-Morphing.git
cd Face-Morphing
pip install -e .

Requirements

  • Python 3.9 - 3.12
  • Works on Linux / macOS / Windows
  • Key dependencies: mediapipe, opencv-python, scipy, numpy

CLI Usage

Morph all images from a folder:

facemorph --input-dir images_dir

If --output is not provided, FaceMorph auto-generates a name like: output_24.02.2026_02.22.17_20fps.mp4

Skip alignment:

facemorph --input-dir images_dir --no-align

Use parallel workers for speed:

facemorph --input-dir images_dir --workers 4

Other options:

  • --duration 3.0: Seconds per transition
  • --fps 30: Video frame rate
  • --output output.mp4: Custom output file
  • --aligned-dir aligned_images: Directory for aligned images
  • --output-size 1024: Video resolution (aligned only)
  • --guideline: Draw triangulation lines
  • --workers: Number of parallel workers (default: 1)
  • --show-native-logs: Show MediaPipe logs

If an image contains multiple faces, FaceMorph automatically uses the largest detected face. Also, it skips images where it does not detect a face.

Python API

Morph Images

from facemorph import morph_folder, morph_images

# Morph a folder of images
morph_folder(
    input_dir="images_dir",
    output_path="output.mp4",
    align=True,
    workers=4,
)

# Morph specific images
paths = ["a.jpg", "b.jpg", "c.jpg"]
morph_images(paths, duration=3.0, fps=30, workers=4)

Align Faces Only

from facemorph import align_folder, align_images, align_image

# Align a folder
aligned_paths = align_folder(
    input_dir="images",
    output_dir="aligned_images",
)

# Align specific images
aligned_paths = align_images(
    image_paths=["images/1.png", "images/2.png"],
    output_dir="aligned_images_custom",
)

# Align a single image
align_image(
    source_path="images/1.png",
    destination_path="aligned_images/1_aligned.png",
)

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

facemorph-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

facemorph-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file facemorph-0.1.0.tar.gz.

File metadata

  • Download URL: facemorph-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for facemorph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dcc593674d9300e633196246ee88b7be14cee2f6cdf7d208bc69ec3683064361
MD5 5f744a877eff4482c8a53bc4bb7ca93c
BLAKE2b-256 a98766a842cb8951af4709d2ec9186f61e6dba14768459f697ce1665accc53ad

See more details on using hashes here.

File details

Details for the file facemorph-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: facemorph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for facemorph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0d4120d84a6ad6a926b8e801e5077d492594ca1945eaabbc6cceb308173e116
MD5 fec26491242a9e96887daa0473834383
BLAKE2b-256 bf351bacf0f24ced7eb2a726e9f7abceb6c9e8c9c1bc762c33bdcf5b44b4a179

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page