😊 Python module for face feature changing

Overview

PyWarping

Python module for face feature changing

Installation

pip install pywarping

If you get an error: No such file or directory: 'cmake': 'cmake', you need to make sure cmake is installed. If you're on OSX you can install this via Homebrew with:

brew install cmake

For other platforms please consult the Cmake documentation at https://cmake.org/install/

Usage

For each face in an image define what actions are to be performed on it, pywarping will do the rest. Check out the docs here.

Minimal Example

import matplotlib.pyplot as plt

from pywarping.actions import Chubby, Multiple, Pipeline, Smile
from pywarping.detect import LandmarkFace

img_path = 'path/to/your/image'
img = plt.imread(img_path)

lf = LandmarkFace.estimate(img)

a_per_face = Pipeline([Chubby(), Smile()])
a_all = Multiple(a_per_face)

new_lf, _ = a_all.perform(lf)
new_lf.plot(show_landmarks=False, show_numbers=False)

CLI

pywarping also comes with a CLI that exposes some of its functionality. You can list the commands with pw --help:

Usage: pw [OPTIONS] COMMAND [ARGS]...

  Automated face warping tool.

Options:
  --help  Show this message and exit.

Commands:
  list     List available actions.
  perform  Take an action.

To perform an action (Smile in the example below) and plot the result on the screen

pw perform Smile INPUT_IMG_PATH

or if you want to create a new image and save it

pw perform Smile INPUT_IMG_PATH OUTPUT_IMG_PATH

Notes

By default we are using a pretrained landmark model from https://github.com/davisking/dlib-models.

License

This Project Has Been MIT Licensed

You might also like...
Swapping face using Face Mesh with TensorFlow Lite
Swapping face using Face Mesh with TensorFlow Lite

Swapping face using Face Mesh with TensorFlow Lite

Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels.
Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels.

The Face Synthetics dataset Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels. It was introduced in ou

Face Library is an open source package for accurate and real-time face detection and recognition
Face Library is an open source package for accurate and real-time face detection and recognition

Face Library Face Library is an open source package for accurate and real-time face detection and recognition. The package is built over OpenCV and us

VGGFace2-HQ - A high resolution face dataset for face editing purpose
VGGFace2-HQ - A high resolution face dataset for face editing purpose

The first open source high resolution dataset for face swapping!!! A high resolution version of VGGFace2 for academic face editing purpose

A large-scale face dataset for face parsing, recognition, generation and editing.
A large-scale face dataset for face parsing, recognition, generation and editing.

CelebAMask-HQ [Paper] [Demo] CelebAMask-HQ is a large-scale face image dataset that has 30,000 high-resolution face images selected from the CelebA da

AI Face Mesh: This is a simple face mesh detection program based on Artificial intelligence.

AI Face Mesh: This is a simple face mesh detection program based on Artificial Intelligence which made with Python. It's able to detect 468 different

Face and Pose detector that emits MQTT events when a face or human body is detected and not detected.
Face and Pose detector that emits MQTT events when a face or human body is detected and not detected.

Face Detect MQTT Face or Pose detector that emits MQTT events when a face or human body is detected and not detected. I built this as an alternative t

Genetic feature selection module for scikit-learn

sklearn-genetic Genetic feature selection module for scikit-learn Genetic algorithms mimic the process of natural selection to search for optimal valu

Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or columns of a 2d feature map, as a standalone package for Pytorch
Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or columns of a 2d feature map, as a standalone package for Pytorch

Triangle Multiplicative Module - Pytorch Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or c

Comments
  • Cant seem to install pywarping

    Cant seem to install pywarping

    This is the error when I try to install it with pip(Pip version 21.1.2, python version 3.9.1)

    `Collecting pywarping Using cached pywarping-0.2-py3-none-any.whl Requirement already satisfied: scikit-image in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from pywarping) (0.18.2) Requirement already satisfied: opencv-python in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from pywarping) (4.5.2.52) Requirement already satisfied: matplotlib>=2.0.0 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from pywarping) (3.4.2) Collecting dlib Using cached dlib-19.22.0.tar.gz (7.4 MB) Requirement already satisfied: click>=7.0 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from pywarping) (7.1.2) Requirement already satisfied: numpy>=1.16.4 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from pywarping) (1.20.0) Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.0.0->pywarping) (1.3.1) Requirement already satisfied: pyparsing>=2.2.1 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.0.0->pywarping) (2.4.7) Requirement already satisfied: cycler>=0.10 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.0.0->pywarping) (0.10.0) Requirement already satisfied: pillow>=6.2.0 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.0.0->pywarping) (8.1.2) Requirement already satisfied: python-dateutil>=2.7 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.0.0->pywarping) (2.8.1) Requirement already satisfied: six in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from cycler>=0.10->matplotlib>=2.0.0->pywarping) (1.15.0) Requirement already satisfied: networkx>=2.0 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from scikit-image->pywarping) (2.5.1) Requirement already satisfied: scipy>=1.0.1 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from scikit-image->pywarping) (1.6.3) Requirement already satisfied: imageio>=2.3.0 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from scikit-image->pywarping) (2.9.0) Requirement already satisfied: tifffile>=2019.7.26 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from scikit-image->pywarping) (2021.6.14) Requirement already satisfied: PyWavelets>=1.1.1 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from scikit-image->pywarping) (1.1.1) Requirement already satisfied: decorator<5,>=4.3 in c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages (from networkx>=2.0->scikit-image->pywarping) (4.4.2) Building wheels for collected packages: dlib Building wheel for dlib (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'c:\users\saketh\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py'"'"'; file='"'"'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\saketh\AppData\Local\Temp\pip-wheel-3lg422aj' cwd: C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12
    Complete output (58 lines): running bdist_wheel running build running build_py package init file 'tools\python\dlib_init_.py' not found (or not a regular file) running build_ext Building extension for Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\build\lib.win-amd64-3.9 -DPYTHON_EXECUTABLE=c:\users\saketh\appdata\local\programs\python\python39\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\build\lib.win-amd64-3.9 -A x64' -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:5 (message):

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    You must use Visual Studio to build a python extension on windows.  If you
    are getting this error it means you have not installed Visual C++.  Note
    that there are many flavors of Visual Studio, like Visual Studio for C#
    development.  You need to install Visual Studio for C++.
    
    
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    

    -- Configuring incomplete, errors occurred! Traceback (most recent call last): File "", line 1, in File "C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py", line 222, in setup( File "c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages\setuptools_init_.py", line 153, in setup return distutils.core.setup(**attrs) File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\core.py", line 148, in setup dist.run_commands() File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages\wheel\bdist_wheel.py", line 299, in run self.run_command('build') File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py", line 134, in run self.build_extension(ext) File "C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File "c:\users\saketh\appdata\local\programs\python\python39\lib\subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\build\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=c:\users\saketh\appdata\local\programs\python\python39\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\build\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.

    ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib, pywarping Running setup.py install for dlib ... error ERROR: Command errored out with exit status 1: command: 'c:\users\saketh\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py'"'"'; file='"'"'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\saketh\AppData\Local\Temp\pip-record-j6g7aj6l\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\saketh\appdata\local\programs\python\python39\Include\dlib' cwd: C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12
    Complete output (60 lines): running install running build running build_py package init file 'tools\python\dlib_init_.py' not found (or not a regular file) running build_ext Building extension for Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\build\lib.win-amd64-3.9 -DPYTHON_EXECUTABLE=c:\users\saketh\appdata\local\programs\python\python39\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\build\lib.win-amd64-3.9 -A x64' -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:5 (message):

      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
      You must use Visual Studio to build a python extension on windows.  If you
      are getting this error it means you have not installed Visual C++.  Note
      that there are many flavors of Visual Studio, like Visual Studio for C#
      development.  You need to install Visual Studio for C++.
    
    
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    
    
    -- Configuring incomplete, errors occurred!
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py", line 222, in <module>
        setup(
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages\setuptools\__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\command\install.py", line 546, in run
        self.run_command('build')
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py", line 134, in run
        self.build_extension(ext)
      File "C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py", line 171, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:\users\saketh\appdata\local\programs\python\python39\lib\subprocess.py", line 373, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\saketh\\AppData\\Local\\Temp\\pip-install-n2rkpdbi\\dlib_d0a2d4f321944269b438c57829027f12\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\saketh\\AppData\\Local\\Temp\\pip-install-n2rkpdbi\\dlib_d0a2d4f321944269b438c57829027f12\\build\\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=c:\\users\\saketh\\appdata\\local\\programs\\python\\python39\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\saketh\\AppData\\Local\\Temp\\pip-install-n2rkpdbi\\dlib_d0a2d4f321944269b438c57829027f12\\build\\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.
    ----------------------------------------
    

    ERROR: Command errored out with exit status 1: 'c:\users\saketh\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py'"'"'; file='"'"'C:\Users\saketh\AppData\Local\Temp\pip-install-n2rkpdbi\dlib_d0a2d4f321944269b438c57829027f12\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\saketh\AppData\Local\Temp\pip-record-j6g7aj6l\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\saketh\appdata\local\programs\python\python39\Include\dlib' Check the logs for full command output.`

    opened by RandomTextWritten 3
  • Error in using pywarping

    Error in using pywarping

    I have finally downloaded visual studio 2019 C++(finally) aaaand I get this error :C

    Exception has occurred: AttributeError module 'urllib' has no attribute 'request' File "C:\Users\saketh\OneDrive\Documents\Code\Python\pywarpingtest.py", line 12, in <module> lf = LandmarkFace.estimate(img)

    opened by RandomTextWritten 6
Releases(0.2)
Owner
Dopevog
| Hey πŸ‘‹ | Β―\_(ツ)_/Β― | 14 |
Dopevog
Changing the Mind of Transformers for Topically-Controllable Language Generation

We will first introduce the how to run the IPython notebook demo by downloading our pretrained models. Then, we will introduce how to run our training and evaluation code.

IESL 20 Dec 6, 2022
Python tools for 3D face: 3DMM, Mesh processing(transform, camera, light, render), 3D face representations.

face3d: Python tools for processing 3D face Introduction This project implements some basic functions related to 3D faces. You can use this to process

Yao Feng 2.3k Dec 30, 2022
Face-Recognition-Attendence-System - This face recognition Attendence system using Python

Face-Recognition-Attendence-System I have developed this face recognition Attend

Riya Gupta 4 May 10, 2022
Video-face-extractor - Video face extractor with Python

Python face extractor Setup Create the srcvideos and faces directories Put your

null 2 Feb 3, 2022
img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation

img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation Figure 1: We estimate the 6DoF rigid transformation of a 3D face (rendered in si

VΓ­tor Albiero 519 Dec 29, 2022
Code for HLA-Face: Joint High-Low Adaptation for Low Light Face Detection (CVPR21)

HLA-Face: Joint High-Low Adaptation for Low Light Face Detection The official PyTorch implementation for HLA-Face: Joint High-Low Adaptation for Low L

Wenjing Wang 77 Dec 8, 2022
DVG-Face: Dual Variational Generation for Heterogeneous Face Recognition, TPAMI 2021

DVG-Face: Dual Variational Generation for HFR This repo is a PyTorch implementation of DVG-Face: Dual Variational Generation for Heterogeneous Face Re

null 52 Dec 30, 2022
[TIP 2021] SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction

SADRNet Paper link: SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction Requirements python

Multimedia Computing Group, Nanjing University 99 Dec 30, 2022
Realtime Face Anti Spoofing with Face Detector based on Deep Learning using Tensorflow/Keras and OpenCV

Realtime Face Anti-Spoofing Detection ?? Realtime Face Anti Spoofing Detection with Face Detector to detect real and fake faces Please star this repo

Prem Kumar 86 Aug 3, 2022