Text-to-Image
Diffusers
English
sdxl
sdxl-turbo
stable-diffusion
image-to-image
image-generation
image-editing
fastapi
mps
Instructions to use sujithputta/Lumaforge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use sujithputta/Lumaforge with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("sujithputta/Lumaforge", torch_dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Deploy architectural upgrades: VRAM CPU offloading, sequential task queue, pipeline registry, and SQLite database manager
9748021 | import sqlite3 | |
| import json | |
| import os | |
| from datetime import datetime | |
| class DatabaseManager: | |
| def __init__(self, db_path="lumaforge.db"): | |
| self.db_path = db_path | |
| self.init_db() | |
| def _get_connection(self): | |
| """Creates a new SQLite database connection.""" | |
| conn = sqlite3.connect(self.db_path, check_same_thread=False) | |
| conn.row_factory = sqlite3.Row | |
| return conn | |
| def init_db(self): | |
| """Initializes the database and creates the generations table if it doesn't exist.""" | |
| query = """ | |
| CREATE TABLE IF NOT EXISTS generations ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| session_id TEXT UNIQUE, | |
| prompt TEXT NOT NULL, | |
| expanded_prompt TEXT, -- JSON string | |
| negative_prompt TEXT, | |
| steps INTEGER, | |
| guidance_scale REAL, | |
| seed INTEGER, | |
| aspect_ratio TEXT, | |
| device TEXT, | |
| latency_sec REAL, | |
| memory_used_mb REAL, | |
| status TEXT, -- 'completed', 'refused', 'error' | |
| image_path TEXT, -- Path to the stored file on disk | |
| error_message TEXT, -- Holds error logs if failed | |
| created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
| ); | |
| """ | |
| conn = self._get_connection() | |
| try: | |
| with conn: | |
| conn.execute(query) | |
| print(f"[DatabaseManager] Database initialized at {os.path.abspath(self.db_path)}") | |
| finally: | |
| conn.close() | |
| def log_generation(self, session_id: str, prompt: str, status: str, | |
| expanded_prompt: dict = None, negative_prompt: str = None, | |
| steps: int = None, guidance_scale: float = None, | |
| seed: int = -1, aspect_ratio: str = "1:1", device: str = "mps", | |
| latency_sec: float = 0.0, memory_used_mb: float = 0.0, | |
| image_path: str = None, error_message: str = None): | |
| """Logs a generation run (success or failure) to the SQLite database.""" | |
| query = """ | |
| INSERT OR REPLACE INTO generations ( | |
| session_id, prompt, expanded_prompt, negative_prompt, steps, | |
| guidance_scale, seed, aspect_ratio, device, latency_sec, | |
| memory_used_mb, status, image_path, error_message | |
| ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); | |
| """ | |
| # Serialize dict to JSON string | |
| expanded_prompt_json = json.dumps(expanded_prompt) if expanded_prompt else None | |
| conn = self._get_connection() | |
| try: | |
| with conn: | |
| conn.execute(query, ( | |
| session_id, prompt, expanded_prompt_json, negative_prompt, steps, | |
| guidance_scale, seed, aspect_ratio, device, latency_sec, | |
| memory_used_mb, status, image_path, error_message | |
| )) | |
| print(f"[DatabaseManager] Logged session {session_id} to database (status: {status})") | |
| except Exception as e: | |
| print(f"[DatabaseManager Error] Failed to log session {session_id}: {e}") | |
| finally: | |
| conn.close() | |
| def get_history(self, limit: int = 50) -> list: | |
| """Retrieves historical generation logs, returning a list of dicts.""" | |
| query = "SELECT * FROM generations ORDER BY created_at DESC LIMIT ?;" | |
| conn = self._get_connection() | |
| try: | |
| cursor = conn.cursor() | |
| cursor.execute(query, (limit,)) | |
| rows = cursor.fetchall() | |
| history = [] | |
| for row in rows: | |
| item = dict(row) | |
| # Deserialize expanded prompt back to dict | |
| if item["expanded_prompt"]: | |
| try: | |
| item["expanded_prompt"] = json.loads(item["expanded_prompt"]) | |
| except Exception: | |
| pass | |
| history.append(item) | |
| return history | |
| except Exception as e: | |
| print(f"[DatabaseManager Error] Failed to retrieve history: {e}") | |
| return [] | |
| finally: | |
| conn.close() | |