Spaces:
Running
StoryCraftAI
Learn how to automate story generation using deep learning and deploy a full-featured web application with CI/CD.
Project Description
StoryCraftAI is an automatic story generation system built entirely from scratch using deep learning. This project covers the entire pipeline—from scraping and preprocessing classic short stories to training various neural network architectures and generating creative narratives from a user-provided seed text.
Key Features
- Data Scraping & Preprocessing:
- Automatically scrapes classic short stories from classicshorts.com.
- Cleans text by removing unwanted characters and tokenizes sentences into words.
- Multiple Model Architectures:
- GRU & LSTM: Optimized for sequence prediction.
- Bidirectional Models: (Bidirectional-LSTM and Bidirectional-GRU) Capture richer context.
- Hybrid Approaches: Combine strengths of different models for better performance.
- Training & Evaluation:
- Generates training sequences (50 words as input and 1 as output).
- Tracks performance with accuracy and loss metrics.
- Saves training history for visualization.
- Interactive Web Application:
- Flask-based web interface for real-time story generation.
- CI/CD & Deployment:
- Deployed on Hugging Face Spaces with continuous integration via GitHub Actions.
Getting Started
Prerequisites
- Python 3.8 or later.
- Virtual environment (recommended).
Installation
Clone the repository:
git clone https://github.com/yourusername/StoryCraftAI.git cd StoryCraftAICreate and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtDownload NLTK data:
python -c "import nltk; nltk.download('punkt')"Run the application locally:
python app.py
Training the Models
Pipeline Overview
- Data Scraping: Fetches stories from classicshorts.com.
- Preprocessing: Tokenizes text and creates sequences of 51 tokens (50 input, 1 target).
- Model Building: Supports architectures like
gru,lstm,bi_di_gru, andbi_di_lstm. - Training: Uses categorical crossentropy loss. Training logs and performance graphs are generated.
Execution
Run the training scripts using Jupyter notebooks in the Notebooks/ folder or directly from the command line. Save the trained model, tokenizer, and training history in the Models/ directory.
Deployment
Using Docker
- Build and run the Docker container locally:
docker build -t storycraftai . docker run -p 7860:7860 storycraftai
CI/CD on Hugging Face Spaces
- Configured for CI/CD using GitHub Actions. Every push to the
mainbranch triggers an automated rebuild and redeployment.
Contributing
Contributions are welcome! Please:
- Fork the repository.
- Create a new branch.
- Submit a pull request detailing your modifications.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For questions or feedback:
- Email: imamitsingh958@gmail.com
- GitHub: @amitsingh-24
- Linkedin: @Linkedin
Enjoy creating and exploring creative stories with StoryCraftAI!