Metadata-Version: 2.1
Name: tinyface
Version: 1.0.0
Summary: The minimalist face swapping tool that just works.
Home-page: https://del.wang
License: MIT
Keywords: ai,face swap,facefusion,insightface
Author: Del Wang
Author-email: hello@xbox.work
Maintainer: Del Wang
Maintainer-email: hello@xbox.work
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: async-tasks-python (>=1.0.0,<2.0.0)
Requires-Dist: filetype (>=1.2.0,<2.0.0)
Requires-Dist: numpy (>=2.1.2,<3.0.0)
Requires-Dist: onnx (>=1.17.0,<2.0.0)
Requires-Dist: onnxruntime (>=1.20.0,<2.0.0)
Requires-Dist: opencv-python (>=4.10.0.84,<5.0.0.0)
Requires-Dist: pooch (>=1.8.2,<2.0.0)
Requires-Dist: tqdm (>=4.67.0,<5.0.0)
Project-URL: Changelog, https://github.com/idootop/TinyFace/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/idootop/TinyFace/README.md
Project-URL: Repository, https://github.com/idootop/TinyFace
Description-Content-Type: text/markdown

# TinyFace

<a href="https://pypi.python.org/pypi/tinyface"><img src="http://img.shields.io/pypi/v/tinyface.svg" alt="Latest version on PyPI"></a> <a href="https://pypi.python.org/pypi/tinyface"><img src="https://img.shields.io/pypi/pyversions/tinyface.svg" alt="Compatible Python versions."></a>

TinyFace is designed as a lightweight Python library with a simplified command-line interface, making it easy for both developers and users to perform face swaps.

## Features

- **Minimalist design**: Focuses solely on face swapping with optimized speed and minimal dependencies.
- **Easy-to-use API**: Integrate face swapping into your own projects with just a few lines of code.
- **Single and multi-face support**: Swap a single face or multiple faces in one go.
- **Command-line tool**: Easily perform face swaps directly from the terminal.

## Installation

Install `tinyface` with pip:

```bash
pip install tinyface
```

## Usage

```python
import cv2

from tinyface import FacePair, TinyFace

# Load input images
input_img = cv2.imread("input.jpg")
reference_img = cv2.imread("reference.jpg")
destination_img = cv2.imread("destination.jpg")

# Initialize the TinyFace instance
tinyface = TinyFace()

# (Optional) Prepare models (downloads automatically if skipped)
tinyface.prepare()

# Detect faces in the images
faces = tinyface.get_many_faces(input_img)
reference_face = tinyface.get_one_face(reference_img)
destination_face = tinyface.get_one_face(destination_img)

# Swap a single face
output_img = tinyface.swap_face(input_img, reference_face, destination_face)

# Swap multiple faces
output_img = tinyface.swap_faces(
    input_img,
    face_pairs=[FacePair(reference=reference_face, destination=destination_face)],
)
cv2.imwrite("out.jpg", output_img)
```

## Commands

```bash
usage: tinyface swap [-h] -i INPUT -r REFERENCE -d DESTINATION [-s SAVE] [-w WORKERS]

options:
  -h, --help            Show this help message and exit
  -i INPUT, --input INPUT
                        Path to the input image(s)
  -r REFERENCE, --reference REFERENCE
                        Path to the reference face image(s)
  -d DESTINATION, --destination DESTINATION
                        Path to the destination face image(s)
  -s SAVE, --save SAVE  Save path for output image(s)
  -w WORKERS, --workers WORKERS
                        Number of worker threads for parallel processing
```

## Disclaimer

This software is intended to contribute positively to the AI-generated media field, helping artists with tasks like character animation and clothing model creation.

Please use responsibly. If working with real faces, always obtain consent and label deepfakes clearly when sharing. The developers are not responsible for any misuse or legal consequences.

## Credits

This project is built upon [@henryruhs](https://github.com/henryruhs)'s work on [facefusion](https://github.com/facefusion/facefusion). TinyFace retains only the minimal dependencies required for face swapping, optimizing both speed and size.

## License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

> **Note:** TinyFace relies on third-party pre-trained models, each with their own licenses and terms.
