此仓库提供了krea2-identity-edit LoRA背后的实际训练代码,作为ai-toolkit的扩展,实现基于指令的、参考图像条件的编辑,并与推理节点的几何结构精确匹配。

Stars

11

7 天增长

暂无数据

Fork 数

1

开放 Issue

1

开源协议

Apache-2.0

最近更新

2026-07-29

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它是身份编辑LoRA的官方训练栈,直接匹配comfyui-krea2edit推理节点,确保训练好的LoRA不会出现错位,并提供详细的VRAM基准和安全检查。

适合谁使用

  • 使用Krea 2进行图像编辑的AI艺术家和开发者
  • 想要训练自定义编辑LoRA的comfyui-krea2edit推理节点用户
  • 需要精确参考条件编辑和流匹配的实践者
  • 愿意使用命令行和YAML配置(非Web UI)的高级用户

典型使用场景

  • 训练个性化身份编辑LoRA用于换脸或物体替换
  • 创建两阶段训练流程(512px为主,1024px收尾)
  • 使用仅目标图像的常规T2I数据集作为正则化
  • 根据自定义数据集调整默认配置(如接地分辨率)

项目优势

  • 几何结构与推理节点精确匹配,防止坐标偏差导致接缝伪影
  • 启动时审计拒绝错误配置(如未配对的图像、翻转增强、卸载文本编码器)
  • 提供不同配置下的实测VRAM需求,帮助选择合适的硬件
  • 支持双参考训练(需设置multi_ref)并详细说明缓存注意事项

使用前须知

  • 需要Python 3.10+和ai-toolkit的特定依赖,可能存在环境问题
  • 不支持批量大小>1、训练中样本预览或16 GB VRAM显卡
  • 不支持Web UI,只能通过命令行手动编写YAML配置文件
  • 文本嵌入缓存会固定接地尺度,牺牲尺度鲁棒性以节省VRAM(24 GB显卡必需)

README 快速开始

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.

项目描述

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.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

lopopolo
精选
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 与机器学习AI 智能体
2,390
slvDev
精选
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 与机器学习大语言模型
1,960
littledivy
精选
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 与机器学习
1,482