Skip to main content

The minimalist face swapping tool that just works.

Project description

TinyFace

Latest version on PyPI Compatible Python versions.

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:

pip install tinyface

Usage

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

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's work on 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 file for details.

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

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

tinyface-1.0.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

tinyface-1.0.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file tinyface-1.0.1.tar.gz.

File metadata

  • Download URL: tinyface-1.0.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.6.0

File hashes

Hashes for tinyface-1.0.1.tar.gz
Algorithm Hash digest
SHA256 243e4dc020d941030da9621ba90ab0334cbb18f00b4f376e25e01a1c4bed743b
MD5 15458685224e2a067bc0bf15bf0abd32
BLAKE2b-256 cb9a413bc4d00b450b90bfa7ac6ebba972d47bacaf6a39284f852b3d7fe78eb7

See more details on using hashes here.

File details

Details for the file tinyface-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tinyface-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.6.0

File hashes

Hashes for tinyface-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc4e3b75feee743843b0dfc9c60d276443d153c809c9720790be33ed950ab15
MD5 9ae994b33adca0837fa034007ebe2f28
BLAKE2b-256 226cc6526fc1afeadd51dd17eec82fd4934a0dfc59224d61f89bc7f18604759d

See more details on using hashes here.

Supported by

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