Generate a face-morphing video from two face images
Project description
Morphace
Generate a face-morphing video from two face images.
Morphace detects facial landmarks, aligns two faces, blends between them, and exports the result as an MP4 video.
Features
- Generate smooth MP4 face-morphing videos from two face images.
- Align and crop portraits before morphing for better results.
- Batch-process folders of images with automatic face detection.
- Customize video length, frame rate, and output location.
Video Example
Table of Contents
Requirements
Morphace requires:
- Python 3.12 or newer.
- FFmpeg installed and available on your system
PATH.
The required Python packages are installed automatically when you install Morphace.
You can verify that FFmpeg is available by running:
ffmpeg -version
Face landmark model
Morphace also requires a face landmark model file to detect and align faces. The model is not bundled with Morphace, so download it once after installing:
morphace download
By default, the command saves the model in Morphace's
application data directory.
The prep and morph commands look there automatically.
Use --landmark-model with morphace prep or morphace morph only if you
want to use a model file saved somewhere else.
Quick Start
-
Install the Morphace package with pip:
pip install morphace
-
Download the required face landmark model.
morphace download -
Create a morph video:
morphace morph first_image.png second_image.png
-
Open the generated video file
morph.mp4.
How It Works
Morphace detects landmarks in both images, aligns the faces to a shared shape, warps each frame between the two faces, blends the image content, and encodes the result as an MP4 video.
At a high level, Morphace:
- Detects a face in each source image.
- Finds facial landmarks such as the eyes, nose, mouth, and face outline.
- Aligns both faces to a shared shape.
- Warps and blends the images frame by frame.
- Encodes the generated frames into an MP4 video.
For a more detailed explanation of the landmark detection, triangle mesh, and frame interpolation process, refer to How It Works on the Morphace documentation site.
Morphace CLI
The morphace command provides three subcommands:
| Command | Purpose |
|---|---|
morphace download |
Downloads Morphace's required model file. |
morphace prep |
Prepares aligned square PNG face crops from raw images. |
morphace morph |
Generates an MP4 face-morphing video from two source images. |
Each of these commands is explained briefly below. For full details, refer to CLI Reference on the Morphace documentation site.
download
The download command installs the model file described in
Requirements.
morphace download
By default, the model is saved in Morphace's
application data directory,
where morphace prep and morphace morph can find it automatically. You
usually only need to run this command once after installing Morphace.
To save the model somewhere else, use --save-to:
morphace download --save-to ./model
If a model file already exists, Morphace will not overwrite it unless you
pass --force:
morphace download --force
Use --debug to show more detailed logging if the download fails.
For full details, refer to download CLI Reference on the Morphace documentation site.
prep
Use morphace prep to turn raw portraits into aligned square PNG face crops
before creating a morph.
This step is optional, but recommended when your source images are framed differently. For example, a close-up portrait and a full-body photo may both contain detectable faces, but the morph will usually look better if both faces are aligned and cropped first.
morphace prep images/raw images/aligned
The prep command can process either a single image file or a directory of
images. When processing a directory, Morphace scans the immediate child files
with these extensions: .jpg, .jpeg, .png, .bmp, .tiff, and .webp.
For each detected face, Morphace writes one aligned PNG file. Output files are named with the original file stem and face number, such as:
portrait_face01.png
portrait_face02.png
By default, aligned crops are saved as 1024x1024 PNG images.
Examples
Prepare a directory of images:
morphace prep \
images/raw \
images/aligned
Prepare a single image and save the output beside the original file:
morphace prep images/raw/portrait.jpg
Prepare tighter or wider crops around the detected face:
morphace prep \
images/raw \
images/aligned \
--x-scale 1.2 \
--y-scale 1.3
After preparing your images, choose two aligned PNG files and pass them to
morphace morph:
morphace morph \
images/aligned/person1_face01.png \
images/aligned/person2_face01.png
Common options
--output-sizesets the square crop size in pixels. The default is1024.--x-scalecontrols how much horizontal context is included around the face.--y-scalecontrols how much vertical context is included around the face.--em-scaleshifts the crop center from the eyes toward the mouth.--alphauses transparent padding instead of reflected padding.--forceoverwrites existing prepared images.--landmark-modeluses a custom model path instead of the default download location.
For full details, refer to prep CLI Reference on the Morphace documentation site.
morph
Use morphace morph to generate an MP4 video that smoothly transitions from
one face image to another.
morphace morph images/first.png images/second.png
By default, Morphace writes the result to morph.mp4, creates a 5-second
video, and renders it at 30 frames per second.
The frame count is based on the selected duration and frame rate. With
the defaults, --duration 5 and --fps 30, Morphace generates 150
frames. The first frame matches the first image, the last frame matches
the second image, and the frames between them move through evenly spaced
steps.
For best results, use images where the faces are similarly framed. If your
source images have different crops, angles, or face sizes, run them through
morphace prep first.
Examples
Create a morph video with the default settings:
morphace morph \
images/first.png \
images/second.png
Choose the output file:
morphace morph \
images/first.png \
images/second.png \
--output output/friends_morph.mp4
Create a longer, smoother morph:
morphace morph \
images/first.png \
images/second.png \
--duration 8 \
--fps 60
Show the triangle mesh used for the face warp:
morphace morph \
images/first.png \
images/second.png \
--show-mesh
Common options
--outputsets the MP4 output path. The default ismorph.mp4.--durationsets the video length in seconds. The default is5.--fpssets the output frame rate. The default is30.--show-meshdraws the face-warping mesh over the generated video.--forceoverwrites an existing output video.--landmark-modeluses a custom model path instead of the default download location.--show-ffmpeg-outputshows FFmpeg encoder output instead of only errors.
For full details, refer to morph CLI Reference on the Morphace documentation site.
Tips for Best Results
- Use front-facing portraits when possible.
- Choose images with similar lighting and head angle.
- Run
morphace prepfirst if the faces are different sizes or crops. - Use
--show-meshto inspect how the face geometry is being warped.
License
The code in this project is licensed under the MIT license. See LICENSE.txt for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file morphace-1.0.1.tar.gz.
File metadata
- Download URL: morphace-1.0.1.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61ae43fc19850d4984c0ebdaf2e3b4e11221fb552395b39cd988fce3e85088f3
|
|
| MD5 |
a885cbca86c0cada401bca24243769ef
|
|
| BLAKE2b-256 |
1f8605084edbd398c89779436d9f1179416a8c18c4c0762f74de22396f69cfe3
|
Provenance
The following attestation bundles were made for morphace-1.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on pierow2k/morphace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
morphace-1.0.1.tar.gz -
Subject digest:
61ae43fc19850d4984c0ebdaf2e3b4e11221fb552395b39cd988fce3e85088f3 - Sigstore transparency entry: 1725004524
- Sigstore integration time:
-
Permalink:
pierow2k/morphace@b3094b61777fa82963fc73a3055486891a51eef5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/pierow2k
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@b3094b61777fa82963fc73a3055486891a51eef5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file morphace-1.0.1-py3-none-any.whl.
File metadata
- Download URL: morphace-1.0.1-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b97b7c55a4f66278165b7e513d5654974f9cf80c51c4c2d5a18f53a3b5baf188
|
|
| MD5 |
8e71afbc2ea4a8487f5f03df55c0582b
|
|
| BLAKE2b-256 |
726b08986fa6a61c375b7f4d32b445076ffacbba5592b44e2a3913307134e197
|
Provenance
The following attestation bundles were made for morphace-1.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on pierow2k/morphace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
morphace-1.0.1-py3-none-any.whl -
Subject digest:
b97b7c55a4f66278165b7e513d5654974f9cf80c51c4c2d5a18f53a3b5baf188 - Sigstore transparency entry: 1725004568
- Sigstore integration time:
-
Permalink:
pierow2k/morphace@b3094b61777fa82963fc73a3055486891a51eef5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/pierow2k
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@b3094b61777fa82963fc73a3055486891a51eef5 -
Trigger Event:
push
-
Statement type: