--- title: Pornmaster Krea2 emoji: 🏆 colorFrom: indigo colorTo: yellow sdk: gradio sdk_version: 6.22.0 python_version: '3.12' app_file: app.py pinned: false short_description: Krea 2 PornMaster finetune space. --- # Pornmaster Krea 2 Krea 2 Turbo text-to-image on Gradio, running the ComfyUI backend directly (no ComfyUI server, no custom nodes). Deploy on **ZeroGPU** hardware. Workflow: [`image_krea2_turbo_t2i.json`](https://github.com/Comfy-Org/workflow_templates/blob/main/templates/image_krea2_turbo_t2i.json) Pattern: [Run ComfyUI workflows for free with Gradio on Hugging Face Spaces](https://huggingface.co/blog/run-comfyui-workflows-on-spaces) ## How it works - `app.py` clones the ComfyUI backend (once), downloads the models, loads them at module scope, and runs the flattened workflow via direct node calls inside `generate_image()`, decorated with `@spaces.GPU`. - UNet (diffusion model) comes from **CivitAI**: PornMaster-Krea2 ([model 2735032](https://civitai.com/models/2735032), version V2.5 Turbo / 3171380, fp8). Companion models (text encoder, VAE, LoRA) come from [Comfy-Org/Krea-2](https://huggingface.co/Comfy-Org/Krea-2), which is not gated. ### CivitAI version ladder V2.5 (3171380) is currently **Early Access** on CivitAI (needs Buzz to unlock), so the app automatically tries, in order: 1. `CIVIT_MODEL_VERSION` (default `3171380`, V2.5 Turbo fp8) 2. `CIVIT_FALLBACK_VERSION` (default `3112108`, Turbo V2 FP8) - downloads fine today 3. Stock `krea2_turbo_fp8_scaled.safetensors` from Comfy-Org (last resort) Once V2.5 is unlocked on the CivitAI account, it is used automatically (no code change needed). Set `CIVIT_MODEL_VERSION=3112108` on the Space to force V2. ## Setup 1. Create a Space with **Gradio SDK** (already configured in this repo). 2. Set hardware to **ZeroGPU** (`large` is fine). ZeroGPU PRO or grant required. 3. Add the CivitAI API key as a Space secret named **`CIVIT_API_KEY`**. 4. First cold start downloads ~17.4 GB of models (5-10 min) and clones ComfyUI. After that, ZeroGPU keeps the container disk, so resumes are fast. ## Notes / tuning - **`duration`**: `@spaces.GPU(duration=120)`. Measure worst-case wall time and set `duration = measured * 1.4`. LLM prompt enhancement adds 20-60 s. - **ZeroGPU sizing**: `size="large"` is the default (48 GB VRAM slice on Blackwell). Only switch to `xlarge` (2x quota) if it OOMs. - **Return values**: numpy arrays are returned (never CUDA tensors), required across the ZeroGPU fork boundary. - **No HF token needed**: none of the model repos are gated. ## Why ComfyUI and not diffusers Diffusers does have a `Krea2Pipeline`, but the official diffusers-format repos (`krea/Krea-2-Turbo`) are gated and 26 GB bf16, and there is no tooling to load raw CivitAI state dicts (single-file checkpoints) with diffusers for Krea 2. The ComfyUI backend loads the CivitAI `.safetensors` directly via `UNETLoader` with automatic architecture detection, and Krea 2 LoRAs work natively.