Installation
# Clone the repository
git clone https://github.com/Bili-Sakura/image-generation-case-study.git
cd image-generation-case-study
# Install dependencies
pip install -r requirements.txt
# Optional: Install API dependencies for closed-source models
pip install -r requirements_api.txt
Usage
Option 1: Gradio Web UI (Recommended)
python run.py
This will open a web browser at http://localhost:7860
with an intuitive UI for text-to-image generation.
Option 2: Python API
from src.model_manager import get_model_manager
from src.inference import generate_image
# Load model
manager = get_model_manager()
manager.load_model("stabilityai/stable-diffusion-2-1")
# Generate
image, filepath, seed = generate_image(
model_id="stabilityai/stable-diffusion-2-1",
prompt="A fantasy landscape with mountains and rivers",
num_inference_steps=50,
guidance_scale=7.5,
seed=42
)
Generation Parameters
- Inference Steps: 10-100 (default: 50) - More steps = higher quality but slower
- Guidance Scale: 1.0-20.0 (default: 7.5) - Higher values = stronger prompt adherence
- Image Sizes: 512px to 1280px with multiple presets
- Seed Control: Fixed seed for reproducibility or random (-1)
- Negative Prompts: Supported on compatible models