Code Monkey home page Code Monkey logo

mustachizer's Introduction

Twitter GitHub license PyPI - Python Version

bulb The Idea

The idea behind his project was to propose a solution to mustachize as many faces as possible. So we did it! And because it's funny and we like to share, we made it a twitter bot (@RealStachBot) and a discord bot.

hammer_and_wrench Installation

If you want to use our work locally, just follow instructions below :

Using pip requirements

$ git clone https://github.com/WildSiphon/Mustachizer.git
$ cd Mustachizer
$ pip install -r requirements/mustachizer.txt

Change the file name based on your usage. Choose between mustachizer.txt, twitter_bot.txt or discord_bot.txt

Using Pipenv

$ git clone https://github.com/WildSiphon/Mustachizer.git
$ cd Mustachizer
$ pipenv shell

Using docker

Just kidding, we haven't gone that far.

chart_with_upwards_trendUse

Local use

If you want to mustachize your pictures by yourself, simply run mustachizer.py :

$ python3 mustachizer.py --show "FILE"

Options available

usage: mustachizer.py [-h] [--list-mustaches] [--size {realist,big,massive}] [--type [NAME]] [--show] [--list-formats] [--no-banner] [--output [DIRPATH]] [--log {CRITICAL,ERROR,WARNING,INFO,DEBUG,NOTSET}]
                      [FILES [FILES ...]]

MUSTACHE THE WORLD!! Script to mustachize everything... or almost

positional arguments:
  FILES                 path(s) to the file(s)

optional arguments:
  -h, --help            show this help message and exit

Mustaches parameters:

  --list-mustaches      list all the mustaches types
  --size {realist,big,massive}
                        choose size of the mustache (default is "realist")
  --type [NAME]         choose mustache type (default is "RANDOM")

Settings:

  --show                display the mustachized media(s)
  --list-formats        list all the accepted media formats
  --no-banner           doesn't display banner
  --output [DIRPATH]    choose output location (default is "output/")
  --log {CRITICAL,ERROR,WARNING,INFO,DEBUG,NOTSET}
                        choose logging level (default is "INFO")

Mustaches names: BAMBINO, CAPTAIN_HOOK, DOCTOR_WATSON, EDWARDIAN, FANCY_CURL, HANDLEBAR, HERCULE_POIROT, HULK_HOGAN, KAISER_WILHELM, REVERSE_HANDLEBAR, ROLLIE_FINGERS, SALVADOR_DALI, TRYPHON_TOURNESOL,
WRESTLER

Mustaches available

collection

Demo

Mustachization of a photo!demo

Mustachization of a gif!demo

Twitter use

@RealStachBot is already on twitter. If you want it to mustachize something, just tag it :

  • When you post a picture
  • In the reply of someone's picture

The bot doesn't mustachize when you tag it in a quote RT of a tweet with media.

You can publish your own bot based on our work if, and only if, it brings something different to Twitter. Otherwise make a pull request. If you publish your own bot based on our work, please link the project and our bot in the account description.

Discord use

We published the code for a discord bot but didn't make one public. Feel free to use our project for personal use only, but don't make a public bot with it.

Developers use

Install dev requirements:

$ pip install -r requirements/dev.txt

Then install pre-commit in your git folder:

$ pre-commit install

books Code review

Now that all the script kiddies are trying to mustachize some stuff without reading more, we can talk about how the code works with y'all real mustache growers.

The first toward mustachization is to detect the face. This is done with a Cascade Classifier (depicted in red in the following image).

The goal is to eliminate the big chunks of the image which don't contain any face.

The selected part of the image is then passed through a Local Binary Feature Facemarker which is essentially an AI specialised in putting reference points on a face.

You can see the result here : Before/After Detection

The facemarker outputs a lot of points which we ignore.

Our reference points are in blue on the picture.

We then map those points to a virtual face model using Perspective N Points solving algorithm.

It determines the rotation and translation of the face needed to match the two sets of points like shown in the following picture :

PnP

Beside, we compute a rectangle on the plane parallel to the face. This rectangle is the mustache's bounding box.

We can now use the rotation and translation of the face to determine the perspective transformation matrix to apply to put the flat mustache image into the said box.

We can see the result here :

Perspective process

mustachized_final_debug

Et voilà !

You can now enjoy a pretty mustache !

Final result

Design

Class diagram

Class Diagram

memo Stuff to add

  • Creating mustachizer.py to mustachize locally
  • Improve output of mustachizer
  • Finish the README
  • Comment all the code
  • Implement gif support
  • Implement video support
  • Add options to choose the size of the mustache
  • Implement unittest
  • Add twitter options to pass param (mustache name, size...)
  • Add mustache color management based on hair color
  • Adding more sentences when bot is posting result of mustachisation
  • MORE MUSTACHES (maybe not… but maybe more)

License

GNU General Public License v3.0

mustachizer's People

Contributors

stealthykamereon avatar wildsiphon avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

brahimmade

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.