Skip to content

Better Head Swap. A simple headswap + faceswap implementation.

License

Notifications You must be signed in to change notification settings

Hanzyusuf/BHS-HeadSwap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Head and Face Swapping Software

This is a simple Python program that leverages two different libraries for head and face swapping tasks. It utilizes the 'roop' library for face swapping and the 'HeadSwap' library for head swapping.

Features

  • Head Swapping: Utilizes the 'HeadSwap' library to swap heads in images.
  • Face Swapping: Utilizes the 'roop' library to swap faces in images.
  • Combined Swapping: Capable of performing both head and face swapping tasks.

Note: built and tested on python 3.10.11

Reminder: activate your virtual environment if desired

--- Installation ---

clone and cd into repo

--- Install PIP packages:

if cuda available:

  • pip install -r requirements_cuda.txt

if cuda not available and want to use cpu:

  • pip install -r requirements_cpu.txt

install nvdiffrast:

remove nvdiffrast folder as it is irrelevant now:

  • cd ../
  • rm -r nvdiffrast

install ffmpeg, c++ redist and build tools:

setup pretrained_models dir

--- How To Use ---

To utilize the swapping functionalities of this program, you can run the main.py script with the following command line arguments:

  • --source: Path to the source image file.
  • --target: Path to the target image file.
  • -o, --output: Path to the output image file.
  • --alsoswapface: Optional argument to indicate whether to swap the face after head swapping. If provided, the program will perform face swapping on the output of head swapping. (default: False)
  • --swap: Specify whether to perform head swapping (head) or face swapping (face). The default value is head.

Example Usage:

To perform head swapping:

python main.py --source "path/to/source/image.png" --target "path/to/target/image.png" -o "output/image.png" --swap head

To perform face swapping:

python main.py --source "path/to/source/image.png" --target "path/to/target/image.png" -o "output/image.png" --swap face

To perform both head and face swapping:

python main.py --source "path/to/source/image.png" --target "path/to/target/image.png" -o "output/image.png" --swap head --alsoswapface

Note:

  • Ensure that the paths to source and target images are valid.
  • If virtual environment is activated, the required packages will be automatically used from the virtual environment. Otherwise, ensure that the required packages are installed in your Python environment.
  • For detailed instructions on installation and setup, please refer to the Installation section above.

About

Better Head Swap. A simple headswap + faceswap implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published