Giter Club home page Giter Club logo

pychubby's Introduction

Build Status codecov PyPI version Documentation Status PyPI - Python Version

PyChubby

Tool for automated face warping

intro

Installation

pip install pychubby

If you get an error FileNotFoundError: [Errno 2] 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/

Description

For each face in an image define what actions are to be performed on it, pychubby will do the rest.

Documentation

https://pychubby.readthedocs.io

Minimal Example

import matplotlib.pyplot as plt

from pychubby.actions import Chubbify, Multiple, Pipeline, Smile
from pychubby.detect import LandmarkFace

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

lf = LandmarkFace.estimate(img)

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

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

CLI

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

Usage: pc [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

pc perform Smile INPUT_IMG_PATH

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

pc perform Smile INPUT_IMG_PATH OUTPUT_IMG_PATH

Development

git clone https://github.com/jankrepl/pychubby.git
cd pychubby
pip install -e .[dev]

pychubby's People

Contributors

fgriberi avatar jankrepl avatar pzelnip avatar whatisand 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  avatar  avatar  avatar

pychubby's Issues

.

.

how to move landmark points.. pixel unit?

hello
Thank you for showing interesting code.
I want to move landmark point using class CustomAction.
and move to pixel unit.....
umm.. ex
def perform(self, lf):
a_l = Lambda(x=self.x, y = self.y
specs={'CHIN': (90,90), # x: +90pixel , y: + 90pixel
}
)
but your code works scale parameter...... umm...
I am Junior so I have trouble make class(move pixel unit)..
Could you do me a favor?..

Define new actions

Defining new actions is very easy via the action Lambda. See detailed explanation here: Custom actions

Some ideas

  • Scare
  • Angrify
  • Bore
  • Projective Transform
  • ...

Implement inversion of DF

The goal is to have a possibility to query any pixel in the original image and get
the corresponding pixel in the new image. Currently only works the other way around.

Realtime warping

Interesting work. Is it possible to do it in realtime? Say live on camera video, perform nose slimming.

Make warping faster for big images

Currently transformation shape is identical to the image shape. Interpolations get pretty slow or even lead to memory errors.

How to fix it?
Perform interpolation on a downsampled image and then upsample the transformation.

Cmake a required dependency on osx

Doing pip install pychubby on a OSX machine (Sierra, 10.12.6) with Python 3.7 gives:

$ pip install pychubby
Collecting pychubby
  Downloading https://files.pythonhosted.org/packages/c3/09/5c9dd0c6c6b097118327d1a2f7a163bafc4d80269c102f3e036cb8c530f7/pychubby-0.2-py3-none-any.whl
.... many lines ...

Building wheels for collected packages: dlib, networkx
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/pzelnip/.virtualenvs/temp/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z9/c2zmn4_13b31g4y26q30n5c1x5hbyk/T/pip-install-3qz43g8p/dlib/setup.py'"'"'; __file__='"'"'/private/var/folders/z9/c2zmn4_13b31g4y26q30n5c1x5hbyk/T/pip-install-3qz43g8p/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/z9/c2zmn4_13b31g4y26q30n5c1x5hbyk/T/pip-wheel-pg9zuzb5 --python-tag cp37
       cwd: /private/var/folders/z9/c2zmn4_13b31g4y26q30n5c1x5hbyk/T/pip-install-3qz43g8p/dlib/
  Complete output (53 lines):
  running bdist_wheel
  running build
  running build_py
  package init file 'dlib/__init__.py' not found (or not a regular file)
  running build_ext
  Traceback (most recent call last):
    File "/private/var/folders/z9/c2zmn4_13b31g4y26q30n5c1x5hbyk/T/pip-install-3qz43g8p/dlib/setup.py", line 120, in get_cmake_version
      out = subprocess.check_output(['cmake', '--version'])
    File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
      **kwargs).stdout
    File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
      with Popen(*popenargs, **kwargs) as process:
    File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
      restore_signals, start_new_session)
    File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'cmake': 'cmake'

There was more output, but ultimately the issue was that I didn't have cmake installed. Once I installed it via Homebrew the pip install worked fine.

Should this not be documented in the Readme/docs?

Error on performing action

Installed software

OS: Arch Linux (latest)
Python version: 3.8.6
Pychubby version: 0.2
pip version: 20.2.4

Steps to reproduce

  1. Install pychubby via pip
  2. Run pc (with arguments or without)
    OR
  3. Run sample script
  4. Get error:
Traceback (most recent call last):
  File "/home/liferooter/.local/bin/pc", line 5, in <module>
    from pychubby.cli import cli
  File "/home/liferooter/.local/lib/python3.8/site-packages/pychubby/cli.py", line 8, in <module>
    import pychubby.actions
  File "/home/liferooter/.local/lib/python3.8/site-packages/pychubby/actions.py", line 14, in <module>
    from pychubby.detect import LANDMARK_NAMES, LandmarkFace, LandmarkFaces
  File "/home/liferooter/.local/lib/python3.8/site-packages/pychubby/detect.py", line 5, in <module>
    import dlib
  File "/home/liferooter/.local/lib/python3.8/site-packages/dlib/__init__.py", line 19, in <module>
    from _dlib_pybind11 import *
ImportError: /home/liferooter/.local/lib/python3.8/site-packages/_dlib_pybind11.cpython-38-x86_64-linux-gnu.so: undefined symbol: cblas_dtrsm

(liferooter is my user name)

Thank you for your help!

When i apply a transform to an image, it shrinks the image.

code

from pychubby.actions import OpenEyes

a = OpenEyes(scale=-0.04)
new_lf, df = a.perform(lf)
new_lf.plot(show_landmarks=False)

original image

original

applied imgae

new_lf2

If you look at the top side of the applied image, the image is scaled down with a black area.

Is it possible to transform a face without this being made?

https://pychubby.readthedocs.io/en/latest/source/gallery.html
If you look at the LinearTransform gif on the pychubby official website, you will see the same phenomenon.

Thanks for providing a good reference.

Use pychubby in android using Chaquopy sdk

import matplotlib.pyplot as plt
import numpy as np
import urllib.request as urllib
from pychubby.actions import Smile
from pychubby.detect import LandmarkFace

def makeSmile(filePath):
    
img = plt.imread(filePath)
lf = LandmarkFace.estimate(img)
a = Smile(scale=0.2)
new_lf, df = a.perform(lf) 
new_lf.plot(show_landmarks=False)
return "Task done"

This is my .py code. I am calling makeSmile method from java file and passing the image file as a parameter.
Once the work is done on python side, I need output image in return. I read all the documentation but did not understand what the plot method do ? why it does not return anything ?

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.