Skip to content

Python-based AI image generation tool using Google Gemini. Enhances user prompts with Gemini 1.5 Flash and generates high-quality images using Gemini 2.0 Flash. Outputs Base64-encoded images. Perfect for AI creators, prompt engineers, and developers working with Generative AI tools.

Notifications You must be signed in to change notification settings

ajmal-uk/gemini-image-generation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🎨 AI Image Generator – Python + Gemini

Sample AI Image

A powerful Python tool combining Gemini 1.5 Flash (for AI-powered prompt enhancement) and Gemini 2.0 Flash (for fast, high-quality image generation). Enter a prompt, let AI enhance it, and generate stunning images instantly — outputted directly as Base64 and saved locally.


🧠 Features

  • 📝 Prompt Enhancement: Gemini 1.5 Flash enriches your text prompts for rich image details
  • 🖼️ AI Image Generation: Gemini 2.0 Flash creates high-quality images
  • 🧵 Base64 Encoding: Automatically encodes generated images
  • 🗂️ Local Storage: Saves output in the static/ folder
  • Fast & Developer-Friendly: Ideal for AI creators, developers, and hobbyists

📂 Project Preview

Prompted Output Folder Path Terminal Run
Output Folder Terminal

🚀 Getting Started

1️⃣ Clone Repository

git clone https://github.com/ajmal-uk/image-generation-using-python-google-gemini-image-studio.git
cd image-generation-using-python-google-gemini-image-studio

2️⃣ Install Dependencies

pip install -r requirements.txt

3️⃣ Configure API Keys

Create a .env file in the root directory:

GEMINI_TEXT_API_KEY=your_text_api_key_here
GEMINI_IMAGE_API_KEY=your_image_api_key_here

4️⃣ Run the Script

python main.py

Enter your prompt and the AI-enhanced image will be saved in /static and encoded in Base64.


🛠 Tech Stack

  • Python 3 – Core programming language
  • Google Generative AIgoogle-generativeai SDK for text & image generation
  • dotenv – API key management
  • Base64 – Encoding images for API/web use

🧠 How It Works

  1. Prompt EnhancementGemini 1.5 Flash enriches the user input text.
  2. Image Generation – Enhanced prompt is passed to Gemini 2.0 Flash for creating images.
  3. Base64 Encoding & Storage – Images are saved locally and encoded for flexible usage.

📦 Requirements

google-generativeai
python-dotenv

👨‍💻 Author

Ajmal UK – Passionate about AI, Python, and creative development.


📞 Contact

🌐 Website📧 Email🐦 Twitter🐙 GitHub

About

Python-based AI image generation tool using Google Gemini. Enhances user prompts with Gemini 1.5 Flash and generates high-quality images using Gemini 2.0 Flash. Outputs Base64-encoded images. Perfect for AI creators, prompt engineers, and developers working with Generative AI tools.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages