---
title: TreeAdapter-KleinBase4B
canonical_url: "https://www.modelscope.cn/models/DiffSynth-Studio/TreeAdapter-KleinBase4B"
md_url: "https://www.modelscope.cn/models/DiffSynth-Studio/TreeAdapter-KleinBase4B.md"
repository: DiffSynth-Studio/TreeAdapter-KleinBase4B
last_updated: 2026-07-30
license: "Apache License 2.0"
pipeline_tag: text-to-image-synthesis
tasks:
  - text-to-image-synthesis
base_model_relation: finetune
library_name:
  - pytorch
  - safetensors
frameworks:
  - Pytorch
downloads: 85
stars: 1
---

# TreeAdapter-KleinBase4B

> TreeAdapter-KleinBase4B - DiffSynth-Studio 在 ModelScope 开源的模型。TreeAdapter 是我们设计的细粒度物种图像生成模型，基于林奈分类系统构建层级化LoRA 树同时捕捉该物种独有的细节特征跨物种的共享特征，提升细粒度物种图像生成的准确性与可控性。

DiffSynth-Studio/TreeAdapter-KleinBase4B 是 ModelScope 魔搭社区上的text-to-image-synthesis模型，采用 Apache License 2.0 许可。

- **Repository**: DiffSynth-Studio/TreeAdapter-KleinBase4B
- **License**: Apache License 2.0
- **Tasks**: text-to-image-synthesis
- **Downloads**: 85
- **Stars**: 1
- **Last updated**: 2026-07-30

Source: https://www.modelscope.cn/models/DiffSynth-Studio/TreeAdapter-KleinBase4B

---

## 模型介绍

TreeAdapter 是我们设计的细粒度物种图像生成模型，基于林奈分类系统构建层级化LoRA 树同时捕捉该物种独有的细节特征跨物种的共享特征，提升细粒度物种图像生成的准确性与可控性。

* 技术报告：[arXiv](https://arxiv.org/abs/2607.24215v1)
* 基础模型：[FLUX.2](https://github.com/black-forest-labs/flux2)
* 训练代码：[DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio)

## 数据样例
**TreeAdapter 与领域内模型及闭源大模型的对比**  
下图展示了 TreeAdapter 在细粒度物种图像生成任务上的显著优势，生成结果在准确性和细节丰富度上均优于对比方法。

![图片描述](example/1.png)

---

**专属适配器对细粒度特征生成的关键作用**  
每个物种都分配了可训练的适配器。下图表明，若取消专属适配器，细粒度特征（如羽毛纹理、体态结构）将无法精确还原。
![图片描述](example/Figure3.png)
以鹈鹕属为例，其共享特征“喉囊”在 TreeAdapter 的层级适配器协同作用下，生成效果远优于仅依赖专有适配器的方法，形态更逼真、结构更合理。
![图片描述](example/Figure4.png)

## 推理代码

安装 [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 推理）：
```python
from diffsynth.diffusion.template import TemplatePipeline
from diffsynth.pipelines.flux2_image import Flux2ImagePipeline, ModelConfig
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.dit = pipe.enable_lora_hot_loading(pipe.dit) # Important!
template = TemplatePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[ModelConfig(model_id="DiffSynth-Studio/TreeAdapter-KleinBase4B", origin_file_pattern="iNaturalist/")],
)
name = "Glareola pratincola"
prompt = "A small bird with a long tail and short wings stands on sandy ground. Its plumage is light brown above, white below, with a dark collar around its neck. The background is a blurred expanse of sand."
image = template(
    pipe,
    seed=0, cfg_scale=4, num_inference_steps=40,
    template_inputs = [{"name": name, "prompt": prompt}],
    negative_template_inputs = [{"name": name}],
)
image.save("image.jpg")
```
