GithubHelp home page GithubHelp logo

hriddhidey / visage Goto Github PK

View Code? Open in Web Editor NEW
106.0 7.0 28.0 69.14 MB

Add virtual makeup to picture of a face.

License: MIT License

Python 100.00%
opencv python image-processing face-detection virtual makeup face lipstick visage picture

visage's Introduction

Visage

Add virtual makeup to a picture of a face.

Plain human face. Human face with makeup.
Image without makeup. Image with lipstick and eyeliner.

Installation

MacOS

  1. You need >=Python2.7 and pip to get this working. MacOS comes with Python2.7 installed by default. If you don't have pip, follow these steps to get it -

    • curl -O https://bootstrap.pypa.io/get-pip.py
    • sudo python get-pip.py
    • pip install --upgrade pip
  2. Install Cmake, Boost, and Boost-Python - brew install cmake boost boost-python

If you don't have Homebrew, copy paste the following in your terminal to get it - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  1. See Step 4 - Generic.

Linux

  1. You will need >=Python2.7 and pip to get this working. Kindly figure out how to get the same for your distribution.

  2. You need Cmake, and Boost-Python. To get the same, use yum or apt-get as you please.

sudo yum install cmake boost boost-devel 

Note: You will need C++11 compiler for Cmake. CentOS does not come with the same out of the box. Follow this link's instructions to get it.

Note: Kindly raise issues if you face setup problems on your Linux distributions. I will ammend the instructions to resolve the same.

  1. See Step 4 - Generic.

Generic

  1. Kindly consider using a virtual environment for development. Check out this link for detailed explanations on how to do that. Follow these steps to get up and running quickly -
pip install virtualenv
virtualenv my_project
cd my_project && source bin/activate

Now you can install your python modules and run your code in an isolated chamber. Once you're done, run deactivate to close the virtual environment.

  1. Install the python module requirements by running - pip install pyvisage

Note: If you are not using virtualenv, you might need sudo to make this work.


Usage

The module is named visage, and consists of two classes - Detect Features and ApplyMakeup. You can import, and access their functions to either selectively detect face only, or apply lipstick directly. Kindly read the Wiki for detailed usage.

Example -

Note: You will need a working internet connection the first time you run this, as it will download a predictor file to your project folder the first time.

from visage import ApplyMakeup
AM = ApplyMakeup()
output_file = AM.apply_lipstick('input.jpg',170,10,30) # (R,G,B) - (170,10,30)

This assumes you have a front-facing image of a human face saved in your current directory as input.jpg.


Guidelines for Image

Certain best practices to be followed to ensure optimal detection and application -

  • Positioning: Face the camera directly and position yourself so that your face fills the about 50-70% of the frame. Avoid extreme angles and poses.
  • Expressions: Preferably maintain a neutral expression. Smiles will be detected comfortably, as long as the shape of the mouth and lips aren't too contorted. Remove any dark glasses or tinted lenses, and keep both eyes open for proper application of eyeliner.
  • Lighting: For increased visibility, avoid bright backlighting ( such as the sun, or other bright light sources ), and glare, by taking your photographs under an even light.
  • Orientation: Kindly ensure an upright orientation in portrait mode.

screen shot 2017-08-08 at 12 51 54 pm

  • Focus & Movement: Image focus and blur can have similar effects on performance as low resolution. Thus, make sure your captured image is not blurry. If the camera is having difficulty focusing, you might be too close or too far from the device.

Attributions

I would like to thank Davis E. King who built dlib, for the documentation and sample codes provided, which were a great help in building this.


visage's People

Contributors

hriddhidey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

visage's Issues

Input

I'm finding it difficult to give input images to your code, as elaborate it seems in your wiki as well as the readme, I have not been able to understand the proper method to give input images to both the files, namely "apply_makeup.py" and "detect_features.py". I have created a folder named input in the visage folder and I have kept two images in the same. Will you please help me with the input and output?

ModuleNotFoundError: No module named 'detect_features'

What error? i can't know it :(
File "/Users/kakalot/yLinkee/cv_api/openCV/modules/faceMakeUp.py", line 14, in <module> from visage import ApplyMakeup File "/usr/local/lib/python3.6/site-packages/visage/__init__.py", line 6, in <module> from visage.apply_makeup import ApplyMakeup File "/usr/local/lib/python3.6/site-packages/visage/apply_makeup.py", line 15, in <module> from detect_features import DetectLandmarks ModuleNotFoundError: No module named 'detect_features' File "/usr/local/lib/python3.6/site-packages/visage/__init__.py", line 6, in <module> from visage.apply_makeup import ApplyMakeup File "/usr/local/lib/python3.6/site-packages/visage/apply_makeup.py", line 15, in <module> from detect_features import DetectLandmarks ModuleNotFoundError: No module named 'detect_features'

How to get cheek points?

I am working on this script and unsure on how to get the coordinates for the cheeks?
I used to get the ROI of cheeks, but it is a rectangle. From there im unable to get the pixel coordinates of the ROI.
If you have any better alternatives, do let me know.

ModuleNotFoundError: No module named 'detect_features'

sample code does not see the detect_features module some how, but I can run the apply_makeup.py inside the package. do you have any suggestion? i have not installed it in virtualenv.

caners-MacBook-Pro:MILKLAB canereren$ python3 makeUpTest.py 
Traceback (most recent call last):
  File "makeUpTest.py", line 1, in <module>
    from visage import ApplyMakeup
  File "/Users/canereren/anaconda/lib/python3.6/site-packages/visage/__init__.py", line 6, in <module>
    from visage.apply_makeup import ApplyMakeup
  File "/Users/canereren/anaconda/lib/python3.6/site-packages/visage/apply_makeup.py", line 15, in <module>
    from detect_features  import DetectLandmarks
ModuleNotFoundError: No module named 'detect_features'

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.