Git Product home page Git Product logo

face-swap-opencv-dlib's Introduction

Faceswapping using OpenCV and Dlib

App for Faceswapping using OpenCV, dlib and Tkinter based on this respository for the core of the technique. More about on how it works in this article.

alt text

alt text

Requirements

  • Python 2.7
  • OpenCV 3.0+ with python bindings (needed to visualize the images/video)
  • Numpy
  • Pillow
  • Tkinter
  • Python bindings of dlib.

Easy install

Build OpenCV or install the light version with sudo apt-get install libopencv-dev python-opencv. For Windows users it is always easier to just download the binaries of OpenCV and execute them, see this web page. For TKinter in Linux just execute: apt-get install python-tk (python binaries in windows usually have Tkinter already installed).

For python dependences just execute:

pip install -r requirements.txt

Dlib installation: For Windows Users it can be very hard to compile dlib with python bindings, just follow this simple instruction on how to install dlib in windows the easy way.

For Linux Users make sure you have the prerequisites:

sudo apt-get install build-essential cmake
sudo apt-get install libgtk-3-dev
sudo apt-get install libboost-all-dev

Finally just pip install it with: pip install dlib

Usage

Desktop application

The app has a button to chose an image from the computer, then it shows the chosen image and tries to find faces within the image. If found, it draws green rectangles around them. Then you can click any face and it put that face in the first face found in the Webcam feed. If you want to undo this just click on the image outside any face detected.

python main.py

Real time from WebCam

alt text

If you just want to do a faceswap between two faces (if found) from the feed of the webcam of your pc, just execute another script.

python main_webcam.py

Between images or snap from WebCam

The other script can swap faces between images and save them modified. To change faces between to files execute:

python main_image.py -f <path_to_image> -f2 <path_to_image2> --webcam

To swap only 2 faces within ONE image just type:

python main_image.py -f <path_to_image>

If you want to swap your face with one in a given image type:

python main_image.py -f <path_to_image> --webcam

The images will be saved into the folder imgs with added to the end the word swapped.

Note: If no -f [file] is given, it will bi take the imgs/pitts.jpg as default image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.