Imgen is a local, text-to-image generation application powered by Stable Diffusion v1.5. It features a user-friendly web interface built with Streamlit, allowing users to generate high-quality artwork with customizable styles, negative prompts, and detailed metadata tracking.
Built as part of the Machine Learning Internship Task Assessment.
- Text-to-Image Generation: Converts natural language prompts into high-quality images using the
runwayml/stable-diffusion-v1-5model. - Smart Hardware Detection: Automatically runs on GPU (CUDA) if available. If not, it falls back to CPU with
sequential_cpu_offloadenabled to prevent memory crashes on standard laptops. - Style Presets: One-click prompt enhancement for specific looks:
- 🎬 Cinematic (Photorealistic, 4K)
- 👾 Cyberpunk (Neon, Futuristic)
- 🌸 Anime (Studio Ghibli style)
- 🖌️ Illustration (Vector art, clean lines)
- Advanced Controls: Adjustable Inference Steps, Guidance Scale, and Image Dimensions (256px / 512px).
- Metadata Management: Every generated image is saved with a matching
.jsonfile containing the exact prompt, seed, and settings used to create it. - Secure & Ethical: Includes visible warnings regarding ethical AI usage and content generation.
- Language: Python 3.10
- Interface: Streamlit
- ML Engine: PyTorch & Hugging Face Diffusers
- Environment Management: Pipenv
This project uses Pipenv for dependency management to ensure a reproducible environment.
- Python 3.10+ installed.
- RAM: 16GB recommended (8GB minimum).
- Storage: ~5GB free space (for downloading the AI model).
# Clone the repository
git clone https://github.com/prantikm07/Imgen-Ai-Image-Generator.git
cd Imgen-Ai-Image-Generator
# Install Pipenv (if you don't have it)
pip install pipenv
# Install dependencies from Pipfile
pipenv install# Activate the virtual environment
pipenv shell
# Launch the Streamlit app
streamlit run app.py- Enter Prompt: Type a description of the image you want (e.g., "A futuristic city made of glass").
- Select Style: Choose a preset (e.g., Cyberpunk) from the sidebar to automatically enhance your prompt.
- Adjust Settings:
- Quality (Steps): Higher = better quality but slower (Recommended: 20-30).
- Creativity (Guidance): Controls how strictly the AI follows your text (Recommended: 7.5).
- Generate: Click the Generate button.
- Note for CPU Users: Generation may take 1-3 minutes per image. Please be patient.
- Download: Once finished, view your image and click Download.
ai_image_generator/
├── app.py # Main Streamlit application frontend
├── generator.py # Backend logic for loading the Model & generating images
├── Pipfile # Dependency definition file
├── Pipfile.lock # Locked versions of dependencies
├── README.md # Project documentation
└── generated_images/ # Output folder (Auto-created on first run)
├── img_<timestamp>.png # The generated image
└── img_<timestamp>.json # Metadata (Prompt, Params, Timestamp)- CPU Mode: If no NVIDIA GPU is detected, the app runs in "Standard Mode" (CPU). It utilizes
sequential_cpu_offloadto minimize RAM usage. - Memory: Closing other heavy applications (like Chrome tabs or IDEs) is recommended during generation to free up RAM.
This tool is intended for creative and educational purposes. Users are advised not to generate NSFW, illegal, or offensive content. All generated images are tagged with metadata to trace their origin.
If you have any questions, feel free to contact me via:
- Email: prantik25m@gmail.com
- LinkedIn: Prantik Mukhopadhyay