Giter Club home page Giter Club logo

deep-frost's Introduction

DeepFrost

A poem generator based on text generation using a Gated Recurral Unit or GRU.

DeepFrost can be tested out here!

DeepFrost

How does DeepFrost work?

DeepFrost generates poems that follow a rhyming scheme (provided by the user). The first sentence of the poem is to be entered by the user as a seed input along with the rhyming scheme. Each sentence of the "poem" is generated independently when seeded with the last word of the sentence.

The last word of the sentence is chosen such that it is similar to the last word of the preceeding sentence and such that it follows the rhyming scheme. It uses Word2Vec word embeddings trained on the model's corpus to infer similar words. If no such word is found it chooses a word in the vocabulary that rhymes with the last word of the preceeding sentence. If no rhyming words are found in the vocabulary, the generator stops executing.

This implementation drew inspiration from the paper, Shall I Compare Thee to a Machine-Written Sonnet? An Approach to Algorithmic Sonnet Generation.

How to run Poem Generator

  1. Clone the repo
git clone https://github.com/HackerSpace-PESU/deep-frost
  1. Install the dependences with
pip install -r requirements.txt
  1. To run the poem generator, use
cd src/
flask run

Note - The app directory contains the resources for the Heroku app and hence the scripts will throw errors if you try to run them on localhost. To run locally, use the Flask app resources present in the src directory.

How to use custom training data?

The application has already been trained and uses the models in the model directory to generate. However, the application can also be trained to use custom lyrics or poems.

  1. To train a new model, replace the directory paths in w2v.py and to your training corpora. As an example, a few documents have been included in the data directory.

  2. Train a word2vec embedding model using the following command. This will produce an embedding model and save it in the model directory.

python3 w2v.py
  1. To train the GRU model, first replace the directory path inside train_gru.py to point to your newly created word embedding model. Then run the following command to generate the generator model (also saved in the model directory).
python3 train_gru.py
  1. Replace the paths inside app.py to point to the newly generated models. Run the application using
flask run

Pre-trained Models and Training Corpora

The pre-trained models can be found here as well as in the model directory. They were trained on a corpus of lyrics by Frost, Taylor Swift and John Keats, which can be found in the data directory.

deep-frost's People

Contributors

aditeyabaral avatar chakita avatar devanaggarwal avatar inacior avatar mayank1403 avatar raaahuuulll avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.