Built a Character Portrait Generator that reads books, identifies characters, and generates consistent portraits using ComfyUI (full RAG pipeline, local LLM, open-source)
Reads novels, identifies characters, and creates matching portraits using local ComfyUI.
Developer snorcack has released an open-source pipeline that automatically generates consistent character portraits from novels, addressing a key challenge in AI-generated imagery: maintaining visual coherence across different scenes. The system, built on Python 3.10+, FastAPI, and LangChain, starts by parsing a .txt file of a book and building a vector index using ChromaDB and HuggingFace's all-MiniLM-L6-v2 embedding model. It then augments this with Wikipedia data to identify major characters and baseline personas before performing deep RAG (retrieval-augmented generation) analysis to extract specific details about appearance, clothing, and environment from different scenes.
The pipeline includes an AI casting director that suggests real-world actors (from Hollywood, Bollywood, etc.) as visual bases for characters, with support for specific decades. A genre adaptation feature dynamically modifies clothing, hairstyles, and cinematic styles to fit genres like Horror, Cyberpunk, or Fantasy while preserving core character identity. The generated prompts are injected directly into ComfyUI API-format workflows, with generation progress tracked via Server-Sent Events and images previewed instantly. The frontend is a sleek, dark glassmorphism dashboard built with React and Vite, and the entire stack runs locally using Ollama (defaulting to Gemma4E4B). The project is MIT-licensed and available on GitHub.
- Combines RAG, LLMs (Gemma4E4B via Ollama), and Stable Diffusion (ComfyUI) for fully local character generation from novels.
- Uses ChromaDB vector indexing and HuggingFace embeddings to parse books and extract scene-specific character details.
- Includes AI casting director that suggests real actors as visual bases and genre adaptation for style consistency.
Why It Matters
Automates consistent character portrait generation from books, eliminating manual prompt engineering for authors, game devs, and fans.