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.
If you want to use our work locally, just follow instructions below :
$ 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
$ git clone https://github.com/WildSiphon/Mustachizer.git
$ cd Mustachizer
$ pipenv shell
Just kidding, we haven't gone that far.
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
Demo
@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.
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.
Install dev requirements:
$ pip install -r requirements/dev.txt
Then install pre-commit
in your git folder:
$ pre-commit install
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.
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 :
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 :
Et voilà !
You can now enjoy a pretty mustache !
Creatingmustachizer.py
to mustachize locallyImprove output ofmustachizer
Finish the READMEComment all the codeImplement 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)