Dank Learning: Generating Memes Using Deep Neural Networks
We introduce a novel meme generation system, which given any image can produce a humorous and relevant caption. Furthermore, the system can be conditioned on not only an image but also a user-defined label relating to the meme template, giving a handle to the user on meme content. The system uses a pretrained Inception-v3 network to return an image embedding which is passed to an attention-based deep-layer LSTM model producing the caption - inspired by the widely recognised Show and Tell Model. We implement a modified beam search to encourage diversity in the captions. We evaluate the quality of our model using perplexity and human assessment on both the quality of memes generated and whether they can be differentiated from real ones. Our model produces original memes that cannot on the whole be differentiated from real ones.
Apple App available!
Try the meme generator out for yourself: see https://danklearning.com/
Just here for the data?
The data we scraped using
scraper.py can be found in im2txt/memes (images) and im2txt/captions.txt (associated captions).
Clone the repo
git clone email@example.com:alpv95/MemeProject
Now cd in
Create a virtual environment and activate it
python -m virtualenv venv source venv/bin/activate
Now install dependencies
pip install tensorflow Pillow jupyter
We've forked our own tf-coreml, which you can install in the virtual environment by doing the following:
cd tf-coreml/ pip install -e . cd ..
Copy in the big files (word embedding matrix & trained DNN weights) from this Google Drive: https://drive.google.com/drive/folders/1R8YRzh0LWno6TiQBTtdoNP73D5GiYviF?usp=sharing
cp [path]/REAL_EMBEDDING_MATRIX im2txt/REAL_EMBEDDING_MATRIX cp -r [path]/trainlogIncNEW im2txt/trainlogIncNew
Now you should be all set up.
Get Jupyter notebooks fired up
Navigate in the browser that launched to
im2txt/Meme_Maker.ipynb and follow the steps in the notebook to generate your own memes! Also see
im2txt/model_conversion_debug.ipynb for how we converted the model to tf-coreml for use on iOS.