---
title: KleinBase4B-i2L-v2
canonical_url: "https://www.modelscope.ai/models/DiffSynth-Studio/KleinBase4B-i2L-v2"
md_url: "https://www.modelscope.ai/models/DiffSynth-Studio/KleinBase4B-i2L-v2.md"
repository: DiffSynth-Studio/KleinBase4B-i2L-v2
last_updated: 2026-07-03
license: "Apache License 2.0"
pipeline_tag: text-to-image-synthesis
tasks:
  - text-to-image-synthesis
base_model_relation: finetune
parameters: 2.0B
tensor_type:
  - BF16
library_name:
  - pytorch
  - safetensors
frameworks:
  - Pytorch
downloads: 1340
stars: 1
---

# KleinBase4B-i2L-v2

> KleinBase4B-i2L-v2 - An open-source model by DiffSynth-Studio on ModelScope. i2L (Image to LoRA) 模型是我们设计的特殊模型结构。模型的输入为若干张图片，输出为这些图片训练出的 LoRA 模型。

DiffSynth-Studio/KleinBase4B-i2L-v2 is a 2.0B-parameter text-to-image-synthesis model on ModelScope. licensed under Apache License 2.0.

- **Repository**: DiffSynth-Studio/KleinBase4B-i2L-v2
- **License**: Apache License 2.0
- **Tasks**: text-to-image-synthesis
- **Parameters**: 2.0B
- **Downloads**: 1340
- **Stars**: 1
- **Last updated**: 2026-07-03

Source: https://www.modelscope.ai/models/DiffSynth-Studio/KleinBase4B-i2L-v2

---

## 模型介绍

i2L (Image to LoRA) 模型是我们设计的特殊模型结构。模型的输入为若干张图片，输出为这些图片训练出的 LoRA 模型。

本模型专门增强了风格提取能力，模型能力与上一版本相比有了较大的提升，支持输入任意多张图，能够快速从这些图像中抽取风格信息，并用于生成新的图像。

* 技术报告：[arXiv](https://arxiv.org/abs/2606.13809)
* 基础模型：[FLUX.2-klein-base-4B](https://modelscope.cn/models/black-forest-labs/FLUX.2-klein-base-4B)
* 数据集：[MegaStyle-1.4M](https://modelscope.cn/datasets/Tencent-Hunyuan/MegaStyle-1.4M)
* 训练代码：[DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio)

## 效果展示

提示词：A cat is sitting on a stone.

|输入|输出|输入|输出|
|-|-|-|-|
|![](./assets/image_1_merged.jpg)|![](./assets/image_1_output.jpg)|![](./assets/image_2_merged.jpg)|![](./assets/image_2_output.jpg)|
|![](./assets/image_9_merged.jpg)|![](./assets/image_9_output.jpg)|![](./assets/image_4_merged.jpg)|![](./assets/image_4_output.jpg)|
|![](./assets/image_8_merged.jpg)|![](./assets/image_8_output.jpg)|![](./assets/image_0_merged.jpg)|![](./assets/image_0_output.jpg)|
|![](./assets/image_3_merged.jpg)|![](./assets/image_3_output.jpg)|![](./assets/image_6_merged.jpg)|![](./assets/image_6_output.jpg)|

模型支持任意多张输入图：

|输入图1|输入图2|输入图3|输入图4|输入图5|输入图6|输入图7|输入图8|
|-|-|-|-|-|-|-|-|
|![](./assets/multi_input_0.jpg)|![](./assets/multi_input_1.jpg)|![](./assets/multi_input_2.jpg)|![](./assets/multi_input_3.jpg)|![](./assets/multi_input_4.jpg)|![](./assets/multi_input_5.jpg)|![](./assets/multi_input_6.jpg)|![](./assets/multi_input_7.jpg)|

|输入1张图产生的输出图|输入2张图产生的输出图|输入3张图产生的输出图|输入4张图产生的输出图|
|-|-|-|-|
|![](./assets/multi_output_1.jpg)|![](./assets/multi_output_2.jpg)|![](./assets/multi_output_3.jpg)|![](./assets/multi_output_4.jpg)|

|输入5张图产生的输出图|输入6张图产生的输出图|输入7张图产生的输出图|输入8张图产生的输出图|
|-|-|-|-|
|![](./assets/multi_output_5.jpg)|![](./assets/multi_output_6.jpg)|![](./assets/multi_output_7.jpg)|![](./assets/multi_output_8.jpg)|

## 推理代码

安装 [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio)：

```shell
git clone https://github.com/modelscope/DiffSynth-Studio.git  
cd DiffSynth-Studio
pip install -e .
```

模型推理（以 Diffusion Templates 推理，开启 CFG 增强以提升效果）：

```python
from diffsynth.diffusion.template import TemplatePipeline
from diffsynth.pipelines.flux2_image import Flux2ImagePipeline, ModelConfig
from modelscope import snapshot_download
from PIL import Image
import numpy as np
import torch

pipe = Flux2ImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="black-forest-labs/FLUX.2-klein-base-4B", origin_file_pattern="transformer/*.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.2-klein-4B", origin_file_pattern="text_encoder/*.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.2-klein-4B", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
    ],
    tokenizer_config=ModelConfig(model_id="black-forest-labs/FLUX.2-klein-4B", origin_file_pattern="tokenizer/"),
)
pipe.enable_lora_hot_loading(pipe.dit)
template = TemplatePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[ModelConfig(model_id="DiffSynth-Studio/KleinBase4B-i2L-v2")],
)
snapshot_download("DiffSynth-Studio/KleinBase4B-i2L-v2", allow_file_pattern="assets/*", local_dir="data")
images = [Image.open(f"data/assets/image_1_{i}.jpg") for i in range(4)]
image = template(
    pipe,
    prompt="A cat is sitting on a stone",
    seed=42, cfg_scale=4, num_inference_steps=50,
    template_inputs = [{"image": images}],
    negative_template_inputs = [{"image": [Image.fromarray(np.zeros_like(np.array(i)) + 128) for i in images]}],
)
image.save("image_output.jpg")
```

模型推理（导出 LoRA 模型文件，可[上传到魔搭社区](https://modelscope.cn/models/create?template=text-to-image-lora&from=aigc)并作为预加载 LoRA [继续训练](https://modelscope.cn/aigc/modelTraining)）：

```python
from diffsynth.diffusion.template import TemplatePipeline, ModelConfig
from modelscope import snapshot_download
from safetensors.torch import save_file
from PIL import Image
import torch

template = TemplatePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[ModelConfig(model_id="DiffSynth-Studio/KleinBase4B-i2L-v2")],
)
snapshot_download("DiffSynth-Studio/KleinBase4B-i2L-v2", allow_file_pattern="assets/*", local_dir="data")
images = [Image.open(f"data/assets/image_1_{i}.jpg") for i in range(4)]
lora = template.call_single_side(inputs=[{"image": images}])["lora"]
save_file(lora, "lora.safetensors")
```
