Metadata-Version: 2.4
Name: facemorph
Version: 0.1.0
Summary: Face morphing and alignment package using MediaPipe and OpenCV
Author: FaceMorph Contributors
License: MIT License
        
        Copyright (c) 2026 Robert Sorete
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://pypi.org/project/facemorph/
Project-URL: Repository, https://github.com/Robys01/Face-Morphing
Project-URL: Issues, https://github.com/Robys01/Face-Morphing/issues
Requires-Python: <3.13,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: opencv-python>=4.9
Requires-Dist: scipy>=1.13
Requires-Dist: mediapipe<0.10.30,>=0.10.11
Requires-Dist: Pillow>=10.0
Requires-Dist: tqdm>=4.66
Dynamic: license-file

# 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**


<p align="center">
  <img src="assets/demo_01.gif" alt="FaceMorph demo 1" width="380" />
  <img src="assets/demo_02.gif" alt="FaceMorph demo 2" width="380" />
</p>



## Install

```bash
pip install facemorph
```

Or from this repo:

```bash
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:

```bash
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:

```bash
facemorph --input-dir images_dir --no-align
```

Use parallel workers for speed:

```bash
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

```python
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

```python
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](LICENSE) file for details.


