A Django web application for generating visual stories using AI. Input your story text, and the app will automatically extract characters and scenes, then generate images for each scene using Google's Gemini (Nano Banana) model.
- Project Management: Create and manage multiple story projects
- Automatic Story Processing: Extract characters and scenes from story text using OpenAI
- Character Extraction: Automatically identifies main characters with visual descriptions
- Scene Splitting: Intelligently splits stories into illustratable scenes
- Multi-Model Image Generation: Choose between multiple AI models:
- Google Nano Banana (Gemini)
- Stability AI (Stable Diffusion)
- Seedance (Coming Soon)
- Multiple Art Styles: Choose from various art styles (Ghibli, Manga, Pixar, etc.)
- Story Viewer: View your complete illustrated story in a beautiful layout
- Python 3.8+
- Django 5.0+
- API Keys for:
- OpenAI (for text processing)
- Google Gemini (for Google Nano Banana model)
- Stability AI (optional, for Stable Diffusion)
- Seedance (optional, coming soon)
- Clone the repository
cd new-story-generator- Install dependencies
pip install -r requirements.txt- Set up environment variables Copy the example env file and add your API keys:
cp .env.example .envEdit .env and add your API keys:
OPENAI_KEY=your_openai_api_key_here
GOOGLE_API=your_google_gemini_api_key_here
STABILITY_API_KEY=your_stability_api_key_here # Optional
SEEDANCE_API_KEY=your_seedance_key_here_when_available # Future
- Run database migrations
python manage.py makemigrations
python manage.py migrate- Create a superuser (optional, for admin access)
python manage.py createsuperuser- Run the development server
python manage.py runserver- Access the application
Open your browser and navigate to:
http://127.0.0.1:8000/
-
Create a New Project
- Click "New Project" on the homepage
- Enter a project name
- Select an art style
- Choose an AI model for image generation
-
Input Your Story
- Go to your project and click "Input Story"
- Paste or type your full story text
- Click "Extract Scenes & Characters"
- The AI will automatically extract characters and split the story into scenes
-
Generate Images
- Click on any scene to open the Scene Manager
- Review and edit the scene prompt if needed
- Click "Generate Image with [Your Selected Model]"
- Wait for the image to be generated
-
View Your Story
- Click "View Story" to see all scenes with their generated images
- The story viewer displays your complete illustrated story
new-story-generator/
├── manage.py # Django management script
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
├── README.md # This file
├── story_django/ # Django project settings
│ ├── settings.py # Project configuration
│ ├── urls.py # URL configuration
│ └── wsgi.py # WSGI application
├── stories/ # Main Django app
│ ├── models.py # Database models
│ ├── views.py # View controllers
│ ├── urls.py # App URL routing
│ ├── admin.py # Django admin interface
│ ├── services/ # Business logic
│ │ ├── story_processing.py # AI text processing
│ │ └── image_generation.py # Image generation
│ ├── templates/ # HTML templates
│ └── migrations/ # Database migrations
├── examples/ # Example scripts
│ └── test_image_generation.py # Standalone image generation test
├── media/ # User-uploaded and generated files
├── static/ # CSS, JS, and static assets
└── venv/ # Python virtual environment (not in repo)
- Ghibli Style
- Line Art Style
- Pixel Art Style
- Water Color Style
- Fairy Tale Style
- Game RPG Style
- Manga Style
- Pixar 3D Style
- Anime Style
- Cinematic Style
- OpenAI GPT-4: For extracting characters and scenes from story text
- Google Gemini: Google Nano Banana model for image generation
- Stability AI: Stable Diffusion Ultra for high-quality image generation
- Seedance: (Coming Soon) Future AI model integration
- Missing API Keys: Make sure you've added your API keys to the
.envfile - Image Generation Fails: Check your Google API quota and ensure the Gemini API is enabled
- Story Processing Fails: Verify your OpenAI API key is valid and has sufficient credits
Access the Django admin interface at http://127.0.0.1:8000/admin/ to:
- Manage projects, characters, and scenes
- View and edit generated content
- Monitor system data
Test the image generation functionality without the web interface:
# Basic usage with default watercolor style and Google Nano Banana
python examples/test_image_generation.py
# Use Stability AI model
python examples/test_image_generation.py --model stability_ai
# Specify both style and model
python examples/test_image_generation.py --style pixar-3d --model stability_ai
# Custom output directory
python examples/test_image_generation.py --style manga-style --model google_nano_banana --output my_test_imagesThe example script demonstrates:
- How to use the Django services in standalone scripts
- Character description replacement in prompts
- Image generation with error handling
- Different art style options
To modify the image generation model or add new features:
- Image generation logic:
stories/services/image_generation.py - Story processing logic:
stories/services/story_processing.py - Database models:
stories/models.py - Views and controllers:
stories/views.py
- Images are stored locally in the
media/generated_images/directory - The app uses SQLite database by default (can be changed in settings)
- Character placeholders in scenes use the format
{CharacterName}
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Never commit your
.envfile or expose API keys - All API keys should be stored as environment variables
- The
.gitignorefile is configured to exclude sensitive files