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.
"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.
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.
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 🌏
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:
- Scrape images from memegenerator.net.
python scraper.py
- 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.
- Generate your memes!
python generate_meme.py --img_path <your_image_location>