lbouaraba GitHub avatar

krea2edit-trainer

lbouaraba

This repository provides the actual training code behind the krea2-identity-edit LoRAs, as an extension to ai-toolkit, enabling instruction-based, reference-conditioned editing for Krea 2 models with geometry-matched inference compatibility.

Stars

11

7-day growth

No data

Forks

1

Open issues

1

License

Apache-2.0

Last updated

2026-07-29

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It is the official training stack for the identity-edit LoRAs, directly matching the comfyui-krea2edit inference nodes, ensuring trained LoRAs work correctly without misregistration, and includes detailed VRAM benchmarks and safety checks.

Who it is for

  • AI artists and developers using Krea 2 for image editing
  • Users of comfyui-krea2edit inference nodes who want to train custom edit LoRAs
  • Practitioners needing precise reference-conditioned editing with flow-matching
  • Advanced users willing to use CLI and YAML configs (not web UI)

Use cases

  • Training personalized identity-edit LoRAs for face swap or object replacement
  • Creating two-stage training pipelines (512px then 1024px finishing pass)
  • Using as regularization with targets-only datasets for plain T2I training
  • Adapting the default configs for custom datasets with specific grounding resolutions

Strengths

  • Geometry-matched to inference nodes, preventing seam artifacts from coordinate misalignment
  • Includes startup audits that refuse misconfigured runs (e.g., unpaired targets, flip augmentation, unload text encoder)
  • Provides measured VRAM requirements for various configurations, enabling informed hardware choices
  • Supports two-reference training with multi-ref flag and detailed caching caveats

Considerations

  • Requires Python 3.10+ and ai-toolkit's specific dependencies, with potential environment issues
  • Does not support batch size >1, in-training sample previews, or 16 GB VRAM cards
  • Web UI unsupported; training only via CLI with manual YAML configs
  • Text embedding caching freezes grounding scale, trading off scale robustness for VRAM savings (necessary for 24 GB cards)

README quick start

krea2edit trainer — ai-toolkit extension

Community project — not affiliated with or endorsed by Krea.ai. "Krea" is used descriptively to identify the base model this trainer targets.

Support on Ko-fi — all tips go straight to GPU compute for future versions.

This is the actual training code behind the released krea2-identity-edit LoRAs — not a reimplementation. Its reference geometry is geometry-matched to the comfyui-krea2edit inference nodes (v1.2.4+), so what you train is what the nodes run. "Geometry-matched" is exact about the things that misregister — fit dimensions, crop rectangles, and the centered fractional RoPE offsets are identical — but the two stacks do not use the same resample kernel, so reference pixels differ slightly below the geometry: the fit path resizes with bilinear + antialias here vs bicubic + antialias in the node, the legacy fit_refs: false crop path uses bilinear without antialias, and the grounding downscale uses PIL LANCZOS here vs common_upscale(..., "area") in the node. Geometry is exact; kernels are not.

It adds one model architecture to ai-toolkit:

  • krea2_edit — instruction-based, reference-conditioned editing (the identity-edit recipe): in-context reference tokens + image-grounded text conditioning

(Plain Krea 2 text-to-image training is already built into upstream ai-toolkit as arch: "krea2" — this extension doesn't duplicate it.)

Note on upstream's own edit mode: ai-toolkit's built-in krea2 arch also offers an edit mode (model_kwargs: {edit: true}). It is a different training contract — a "Picture N:"-labeled grounding template and an area-budget reference resize — whereas this extension implements the exact grounding template and fit-to-target-grid reference geometry that the comfyui-krea2edit nodes (and the released krea2-identity-edit LoRAs) use. Both are valid trainers; they are not interchangeable. If you want LoRAs that pair with the identity-edit inference stack, train with arch: "krea2_edit" from this extension.

Install

cd ai-toolkit/extensions
git clone https://github.com/lbouaraba/krea2edit-trainer krea2_edit

That's it — ai-toolkit discovers extensions in that folder.

Description

Community ai-toolkit extension for training Krea 2 identity-edit LoRAs — the training code behind krea2-identity-edit, geometry-matched to the comfyui-krea2edit nodes. Not affiliated with Krea.ai.

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
littledivy
Featured
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI & Machine Learning
1,482