--- title: Krea 2 LoRA Trainer emoji: 🎨 colorFrom: indigo colorTo: yellow sdk: gradio sdk_version: 6.19.0 python_version: '3.12' app_file: app.py hardware: cpu-basic pinned: true hf_oauth: true hf_oauth_scopes: - read-repos - write-repos - manage-repos - jobs short_description: Train Krea 2 LoRAs on your images via HF Jobs --- # Krea 2 LoRA Trainer Train a **DreamBooth-LoRA for Krea 2** from your own images, entirely on Hugging Face infrastructure: - **Sign in with Hugging Face** — the dataset, the job, and the pushed LoRA all run under **your** account and billing (no pasted tokens); - the **Space** (this app, `cpu-basic`) collects your images + hyperparameters and submits a job; - training runs on **HF Jobs** using the diffusers Krea 2 trainer (`examples/dreambooth/train_dreambooth_lora_krea2.py`); - the LoRA is **trained on Krea 2 RAW** and **validated / inferred on Krea 2 Turbo**, then pushed to the Hub model repo you choose. You only pay for the Job's actual GPU runtime. ## How tokens are used Three tokens, three jobs: - **Your OAuth token** (from sign-in) — your dataset repo + the pushed LoRA, under your account/billing. - **`KREA_TOKEN` secret** — downloads the **gated** Krea 2 weights *inside the job* and passes them to the trainer as **local dirs**, so your own token never needs Krea access and the Krea token never touches your repos. - **`CAPTION_HF_TOKEN` secret** — calls the Inference API for **AI captioning** on this Space only (`google/gemma-4-31B-it`, served with vision via the `novita` provider). > Set `KREA_TOKEN` to a token with access to `krea/Krea-2-Raw` + `krea/Krea-2-Turbo`, and > `CAPTION_HF_TOKEN` to any token that can call Inference Providers. ## Captioning Pick whether you're training **a style** or **an object/character** — this drives both the suggested trigger and how images are captioned: - **Style** — captions describe only the *content* (subjects, layout, setting) and end with your style trigger phrase (e.g. *heavy impasto style*), so the model learns the look, not the subjects. - **Object/character** — captions describe the scene and tag the subject with a unique trigger token (e.g. *b3@rcup*). **✨ Suggest** proposes a trigger from 2–3 of your images; **✨ Add AI captions** fills every caption. Everything is editable; blank captions fall back to the trigger. ## Preview gallery & README After training, the job renders a few sample images on **Krea 2 Turbo** with your LoRA and pushes a model-card **README** to the LoRA repo where each image is captioned by its prompt. The showcase prompts are written by the LLM from your concept + trigger (or you can supply your own, one per line, using `` as a placeholder). The trainer's own validation is skipped in favour of this. ## diffusers version The trainer lives in diffusers PR #14046 (branch `krea2-lora`). Once it is merged, set the `DIFFUSERS_REF` Space **variable** to `main` (or a release tag). ## Usage 1. Sign in with Hugging Face. 2. Name your LoRA and pick what you're training — **a style** or **an object/character**. 3. Upload 4–30 images, **✨ Suggest** a trigger, and **✨ Add AI captions** (edit anything). 4. Tweak hyperparameters if you like, choose how many preview samples to render, pick a GPU flavor, and **Submit training job**. 5. Copy the job id into the **Monitor** tab and **Refresh** to stream logs. When it finishes, the LoRA repo has the weights, a preview gallery, and a rich README.