Skip to content

krharitej/Imagine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Imagine – Context-Aware Image Generation

Imagine is a context-aware image generation system built using Stable Diffusion and DreamBooth. It focuses on personalized and realistic image synthesis by learning a specific subject and generating it across diverse environments while preserving identity and semantic consistency.

The system is developed in Python using Hugging Face Diffusers and PyTorch. It fine-tunes the pre-trained CompVis/stable-diffusion-v1-4 model on a custom instance dataset (diffusers/dog-example) along with class images generated for prior preservation. This enables high-quality subject-aware and context-driven image generation.


Key Features

  • Personalized subject learning using DreamBooth
  • Context-based environment adaptation
  • Identity preservation across scenes
  • High-quality realistic synthesis
  • Memory-efficient training on limited GPUs
  • Hugging Face integration

Technologies

  • Python
  • PyTorch
  • Stable Diffusion
  • Hugging Face Diffusers
  • DreamBooth
  • Transformers
  • Accelerate
  • xFormers
  • BitsAndBytes
  • CUDA

Hardware Requirements

  • NVIDIA GPU with CUDA support (minimum 8 GB VRAM, 12 GB+ recommended)
  • CUDA Toolkit 11.7 or newer
  • Compatible NVIDIA Driver
  • Minimum 16 GB system RAM (32 GB recommended for training)
  • At least 20 GB free disk space for models and datasets
  • Tested on Linux and Google Colab (limited support on Windows WSL)

Note: CPU-only execution is not recommended due to high computational requirements.


Dataset and Model

  • Instance Dataset: diffusers/dog-example (Hugging Face)
  • Class Dataset: Auto-generated (prior preservation)
  • Base Model: CompVis/stable-diffusion-v1-4
  • Fine-Tuning Method: DreamBooth

Sample Inputs and Outputs

Input Images (Training Samples)

image image image image image

Generated Outputs

Prompt Output
dog in in beach download
dog in in living room download
my dog teddy in park download
my dog teddy in beach download
my dog teddy playing in beach download
my dog teddy in lawn download
my dog teddy in snow download
tiger in beach (Random prompt without specifying name of trained subject) download

Setup and Installation

Clone the Repository

git clone https://github.com/krharitej/Imagine.git
cd Imagine

Running the Project

Training (Optional – For Custom Subjects)

accelerate launch Imagine.py
  • Ensure dataset paths are correctly configured before training

Inference / Image Generation

python Imagine.py

Or run using Jupyter:

jupyter notebook Imagine.ipynb

System Workflow

Input Images + Prompts → DreamBooth Fine-Tuning → Custom Model → Context-Aware Image Output


Author

K R Haritej


📜 License

This project is intended for educational and research purposes.
Please refer to the respective licenses of Stable Diffusion and DreamBooth.

About

Imagine is a generative model for ‘Context-Aware’ or ‘Subject-based’ image Generation. The model is capable of placing objects in new environments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors