Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Imgen: AI Image Generator

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.


🚀 Features

  • Text-to-Image Generation: Converts natural language prompts into high-quality images using the runwayml/stable-diffusion-v1-5 model.
  • Smart Hardware Detection: Automatically runs on GPU (CUDA) if available. If not, it falls back to CPU with sequential_cpu_offload enabled 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 .json file containing the exact prompt, seed, and settings used to create it.
  • Secure & Ethical: Includes visible warnings regarding ethical AI usage and content generation.

🛠️ Tech Stack

  • Language: Python 3.10
  • Interface: Streamlit
  • ML Engine: PyTorch & Hugging Face Diffusers
  • Environment Management: Pipenv

⚙️ Installation & Setup

This project uses Pipenv for dependency management to ensure a reproducible environment.

1. Prerequisites

  • Python 3.10+ installed.
  • RAM: 16GB recommended (8GB minimum).
  • Storage: ~5GB free space (for downloading the AI model).

2. Clone and Install

# 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

3. Run the Application

# Activate the virtual environment
pipenv shell

# Launch the Streamlit app
streamlit run app.py

🖥️ Usage Guide

  1. Enter Prompt: Type a description of the image you want (e.g., "A futuristic city made of glass").
  2. Select Style: Choose a preset (e.g., Cyberpunk) from the sidebar to automatically enhance your prompt.
  3. 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).
  4. Generate: Click the Generate button.
    • Note for CPU Users: Generation may take 1-3 minutes per image. Please be patient.
  5. Download: Once finished, view your image and click Download.

📂 Project Structure

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)

⚠️ Hardware Notes

  • CPU Mode: If no NVIDIA GPU is detected, the app runs in "Standard Mode" (CPU). It utilizes sequential_cpu_offload to minimize RAM usage.
  • Memory: Closing other heavy applications (like Chrome tabs or IDEs) is recommended during generation to free up RAM.

⚖️ Ethical Use

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.

Contact

If you have any questions, feel free to contact me via:

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages