Skip to content

Generate humorous captions based on the image provided

Notifications You must be signed in to change notification settings

pgplarosa/humournet

Repository files navigation

Humournet

humournet is a set of CLI tools that will let you evaluate your image and outputs a humorous caption. The goal of this project is to provide a little humour despite our current global pandemic because I believe that laughter is the best medicine.

Dataset

"memegenerator.net" is a free online image maker that allows user to add custom resizable text to images, it is also a popular repository of our favorite memes. Data was scraped from this site using scraper.py that outputs the saved images and csv file where the captions for each images are stored. These images and captions are then preprocess by extracting image features, perform text processing, text tokenization, and word embeddings before passing it to our model.

Model Architecture

It uses EfficientNetB2 to extract image features and connects it to a fully connected layer as an encoder, it is then pass to the decoder having LSTM layers with visual attention.

Results

Since during these pandemic days many companies are switching to work from home operation, Let's generate a caption to a man working from home 💻 🏠.

input output

This AI is hilarious 😂. Of course you don't want to sleep at work, and it should be done unless you are going to be 🔥

Let's try another one for a kid having some online learning class.

input output

Hmmm.. I think our AI is implying that we should start from our home before putting a mark in the world 🌏

Usage

Before anything else, please make sure to satisfy all of the prerequisites found in requirements.txt. OK, now that we are ready you can have your humorous captioning AI by excuting the following scripts sequentially:

  1. Scrape images from memegenerator.net.
python scraper.py
  1. Train your models
python train.py --num_epochs 15 --load_models 0

You can have full control on the hyperparameters for your training but the above code works the best for me.

  1. Generate your memes!
python generate_meme.py --img_path <your_image_location>

Authors

References

  1. Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
  2. Neural Machine Translation by Jointly Learning to Align and Translate

Releases

No releases published

Packages

No packages published

Languages