This project generates a 5-step children's story with illustrations based on a user-provided prompt. It uses AI to generate the story and images, and then combines them to create a complete storybook-style output.
- Generates a 5-step story from a simple prompt.
- Creates a unique image for each step of the story.
- Adds the story text as a layer on top of each image.
- Uses Google's Gemini Pro for story generation and Together AI for image generation.
git clone https://github.com/your-username/your-repository-name.git
cd your-repository-nameIt is recommended to use a virtual environment to manage the project's dependencies.
python3 -m venv .venv
source .venv/bin/activateInstall the required Python libraries using pip:
pip install -r requirements.txtThis project requires API keys for Google and Together AI. Create a .env file in the root of the project and add the following lines:
GOOGLE_API_KEY="your_google_api_key"
TOGETHER_API_KEY="your_together_api_key"
Important: This project will not work without these API keys.
Execute the main.py script to generate a story:
python main.pyThe generated images with text will be saved in the images/ directory.
.
├── AI_model/
│ ├── generate_story.py
│ ├── image_generator.py
│ ├── extract_story_data.py
│ └── prompt_templates.py
├── post_image_generation/
│ └── add_text_layer.py
├── images/
│ └── (generated images will be saved here)
├── .env
├── .gitignore
├── main.py
├── requirements.txt
└── README.md
- Story Generation: The
generate_storymodule uses the Google Generative AI model to create a 5-step story based on the user's prompt. - Data Extraction: The
extract_story_datamodule parses the generated story to extract the setting, style, main character, and the 5 story steps. - Image Generation: For each story step, the
image_generatormodule uses the Together AI model to create an image based on the visual description. - Text Overlay: The
add_text_layermodule uses the Pillow library to add the story text to the corresponding image.
Contributions are welcome! Please feel free to submit a pull request or open an issue if you have any suggestions or find any bugs.