TwistedPic is an application of TwistedPair, the LLM distortion pedal. TwistedPic transforms text prompts into images by first distorting texts through rhetorical "distortion pedals" (via TwistedPair REST API) and then generating images with Stable Diffusion XL. Everything runs on a local machine. No cloud, no cost, no Internet required.
User Prompt → TwistedPair Distortion → Prompt Wrapper → SDXL → Generated Image
TwistedPic orchestrates two existing services:
- TwistedPair - Rhetorical text distortion with 6 modes, 5 tones, and 1-10 gain
- Stable Diffusion XL - High-quality image generation
# Ollama server (required for LLM models)
ollama serve # http://localhost:11434
# TwistedPair V2 server (required for distortion)
cd TwistedPair/V2
uvicorn server:app --host 0.0.0.0 --port 8001- CUDA GPU required (SDXL is GPU-intensive)
- Minimum 8GB VRAM recommended
- 20GB disk space for SDXL model download
TwistedPic and Ollama both use GPU resources. By default, TwistedPic automatically cleans up GPU memory after each image generation to prevent monopolizing the GPU and blocking Ollama from using it.
Configuration options in config.py:
# Basic cleanup (recommended - enabled by default)
GPU_MEMORY_CLEANUP = True # Clears CUDA cache after generation
# Advanced cleanup (only if Ollama still can't access GPU)
UNLOAD_MODEL_AFTER_GENERATION = False # Moves model to CPU between generationsSymptoms of GPU contention:
- Ollama runs at 100% CPU usage (instead of using GPU)
- TwistedPic works fine but Ollama becomes very slow
- Need to restart both services to fix
Solutions:
- Basic (enabled by default):
GPU_MEMORY_CLEANUP = True- Usually sufficient - Advanced: Set
UNLOAD_MODEL_AFTER_GENERATION = True- Slower but frees more GPU memory - Alternative: Use smaller image models (SDXL instead of SD3 Large) to reduce GPU memory usage
Install at least one model:
ollama pull mistral:latest
ollama pull llama3.1:8b
ollama pull qwen3:latestpython -m venv .venv
.\.venv\Scripts\Activate.ps1pip install -r requirements.txtNote: First run will download SDXL model (~7GB) from HuggingFace.
TwistedPic/
├── config.py
├── server.py
├── twistedpair_client.py
├── model_registry.py
├── image_generator.py
├── requirements.txt
├── templates/
│ └── index.html
├── static/
│ ├── styles.css
│ └── app.js
└── outputs/ # Auto-created on first run
python server.pyNavigate to http://localhost:5000 in your browser.
- Enter prompt: "A peaceful garden with blooming flowers"
- Set distortion: Mode=Echo-er, Tone=Poetic, Gain=6
- Set image params: Quality=30, Style=7.5, Resolution=Landscape
- Press "Generate Image"
- Wait 10-30 seconds (progress bar updates)
- View result: Image + distorted prompt + image prompt displayed
- Press "Save" to download PNG
- Try different modes (Invert-er flips meaning, What-If-er explores alternatives)
- Adjust gain (1=subtle, 10=intense distortion)
- Change tones (Poetic adds metaphors, Satirical adds irony)
- Tweak image quality (higher steps = more detail but slower)
- DreamSprout - Image generation architecture Github DreamSprout
- TwistedPair V2 - Rhetorical distortion engine Github TwistedPair
- MRA_v3 - Local LLM + RAG + TwistedPair Github my-research_assistant
MIT


