Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Meme_Generator

Dataset

A custom dataset was generated for the use of this project. To achieve this, we scraped an online database of humorous captioned images, known as memes, through their webpage called “meme generator”. To ensure the proper working and focused performance of the model, each meme format was retrieved individually and stored in a separate file for the model’s usage. The size of the datasets for each of the formats ranged from 350 entries to 20000 entries, allowing the observation of the model’s reactions to widely varying dataset sizes.

Methodology

LSTM

LSTM stands for long-short term memory. It is an RNN but overcomes its drawbacks (vanishing or exploding gradient problem). There are sigmoid and tanh activation functions used inside the layer. In the model built in the project, we use ReLU to connect the LSTM layer to other layers. 8 In this model, we performed tokenization, vocabulary for characters. Modules: Keras, numpy and tensorflow Level of prediction: character level Model architecture: Model: "sequential"


Layer (type) Output Shape Param #

lstm (LSTM) (None, 100, 256) 264192


dropout (Dropout) (None, 100, 256) 0


lstm_1 (LSTM) (None, 256) 525312


dropout_1 (Dropout) (None, 256) 0


dense (Dense) (None, 46) 11822

Total params: 801,326 Trainable params: 801,326 9 Non-trainable params: 0


Bidirectional LSTM

BiLSTM is just 2 LSTM layers but one in the forward direction and the other in the backward direction. This approach increases the sheer volume of data available to the model and increases the context availability In this model, we performed tokenization, padding and vocabulary for words(word embedding). Modules:keras, tensorflow, matplotlib, PIL Level of prediction: word level Model architecture: Model: "sequential"


Layer (type) Output Shape Param #

embedding (Embedding) (None, 49, 100) 295500


10 bidirectional (Bidirectional (None, 49, 300) 301200


dropout (Dropout) (None, 49, 300) 0


lstm_1 (LSTM) (None, 100) 160400


dense (Dense) (None, 1477) 149177


dense_1 (Dense) (None, 2955) 4367490

Total params: 5,273,767 Trainable params: 5,273,767 Non-trainable params: 0


GPT 2 (117M) Fine-tuning

GPT 2 is a large-scale unsupervised language model which generates coherent sentences about arbitrary topics. This model can be fine-tuned to specific tasks. OpenAI developed GPT 2 with 40GB of text data and released a sample version as open source for researchers and academics to experiment. GPT 2 is a generative transformer model.

Results

LSTM

Small model: less number of lstm layer Large model: more number of lstm layers

1st try:

No of characters generated: 100 Model: Small model No. of epochs trained: 20 epochs.

Output:

image

2nd try:

No of characters generated: 100 Model: Small No of epochs trained: 50 epochs

output:

image

3rd try:

No of characters generated: 100 Model: Large No of epochs: 100

Output:

image

4th try:

No of characters generated: 100 Model: large No of epochs: 100

Output:

image

Drawback: the model is overfitted as the generated text already exists in the dataset.

Bi-Directional LSTM

image image

Output:

Sample from dataset:

Textbooks y u no have CTRL-F Seed = flavor

Generated text: flavor u no txt y u no talk 2 me no more first years of spot

through morning shows truck morning

Drawback:

the model is underfitted as the generated text shows little variance with different seeds.

GPT Fine-Tuning

Output:

image image image image image

Conclusion

Adding captions to images allows the images to target a wider range of audiences, and can be used by multiple companies to use a single image to construct varying storylines. The project yields a conclusion that while the datasets can produce working results, the improvements in accuracy and quality of the output generated, such as the captions being more humorous and meaningful, when using datasets of increasing size denotes that the performance of the model is directly proportional to the size of the dataset to some extent.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages