Coder Social home page Coder Social logo

face-replace-python's Introduction

Silly Face Replace

This searches for faces within an image and replaces them with the first face found from an image of your choosing. Some crummy bash scripts have been written to help convert video to and from images.

Installation

sudo apt-get install python-opencv
git clone [email protected]:matthewfranglen/face-replace-python.git face-replace
cd face-replace

Conversion

python ferris.py REPLACEMENT_IMAGE REPLACEMENT_IMAGE INPUT_FOLDER/ OUTPUT_FOLDER/

This will convert all images in INPUT_FOLDER. It will replace any faces with REPLACEMENT_IMAGE and save the updated image to OUTPUT_FOLDER.

Altering the Replacement Image

The replacement face can be detected from one image and then taken from another, allowing you to alter the replacement face (such as masking it).

python ferris.py DETECT_IMAGE REPLACE_IMAGE INPUT_FOLDER/ OUTPUT_FOLDER/

Here the DETECT_IMAGE is used to find the face, and then the same area is copied from the REPLACE_IMAGE. It is recommended that these be the same size. The size and position of the detected face is not scaled or moved to match the dimensions of the replacement image.

Converting Video

You can use the scripts in the bin folder to handle videos. This requires ffmpeg. The output video is saved in the mpeg4 format.

bin/strip INPUT_VIDEO INPUT_FOLDER AUDIO_FILE
python ferris.py DETECT_IMAGE REPLACE_IMAGE INPUT_FOLDER/ OUTPUT_FOLDER/
bin/combine OUTPUT_FOLDER AUDIO_FILE OUTPUT_VIDEO

This extracts the video at 25 fps so conversion can take some time. A two minute video is 3,000 frames.

face-replace-python's People

Contributors

matthewfranglen avatar

Watchers

James Cloos avatar Ming Xue avatar

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.