File size: 7,357 Bytes
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263b26f
6daffc2
 
 
 
 
 
0957ad9
 
 
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263b26f
 
 
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0957ad9
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263b26f
6daffc2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
---
license: other
license_name: mg-by-nc-2.0
license_link: https://ids.nus.edu.sg/docs/modelgo/v2/MG-BY-NC/LICENSE
library_name: dflow
pipeline_tag: text-to-image
tags:
  - text-to-image
  - flow-matching
  - pytorch
  - comfyui
  - photography
base_model:
  - google/t5gemma-2-270m-270m
---

# dflow_2b

> [!WARNING]
> **Preview, version 0.22.** The model is still training, so checkpoints and
> behaviour will change between releases. Generations are still uneven, expect
> some seed hunting.

dflow_2b is an indie text-to-image model, trained from scratch on a single GPU,
mostly on photographs and classical art.

It takes ordinary captions and JSON layout captions. The layout format is close
to [MOSS-Image](https://github.com/OpenMOSS/MOSS-Image)'s, and MOSS-Image
layouts are converted internally.

The package contains the weights, the `dflow` inference code and ComfyUI nodes.

[Example gallery](GALLERY.md) · [Manual](MANUAL.md) ·
[Technical report](TECHNICAL_REPORT.md) · [Release notes](RELEASES.md)

<table>
  <tr>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#boardwalk"><img src="assets/gallery/boardwalk.png" width="220" alt="Boardwalk to a rugged coast"></a></td>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#cat_grass"><img src="assets/gallery/cat_grass.png" width="220" alt="Tortoiseshell cat in tall grass"></a></td>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#rooster"><img src="assets/gallery/rooster.png" width="220" alt="Rooster among tropical plants"></a></td>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#man"><img src="assets/gallery/man.png" width="220" alt="Studio portrait of a man"></a></td>
  </tr>
  <tr>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#street"><img src="assets/gallery/street.png" width="220" alt="Narrow street of wooden houses"></a></td>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#constable"><img src="assets/gallery/constable.png" width="220" alt="Landscape oil painting"></a></td>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#poster_jazz"><img src="assets/gallery/poster_jazz.png" width="220" alt="Jazz festival poster from a JSON layout"></a></td>
    <td><a href="https://huggingface.co/data-archetype/dflow_2b/blob/main/GALLERY.md#red_perfume"><img src="assets/gallery/red_perfume.png" width="220" alt="Woman holding a red perfume bottle"></a></td>
  </tr>
</table>

## What's included

- `model.safetensors`: the 2B denoiser.
- `text_encoder/`: the part of
  [T5Gemma 2 270M](https://huggingface.co/google/t5gemma-2-270m-270m) the model
  uses, under the Gemma Terms of Use.
- `dflow/`: the Python inference package.
- `comfyui/`: ComfyUI nodes and example workflows.

The autoencoder, [dinac3_96](https://huggingface.co/data-archetype/dinac3_96),
is our own and downloads automatically on first use. The
[technical report](TECHNICAL_REPORT.md) covers the architecture and training.

## Requirements

Python 3.12 or later, PyTorch 2.13 with CUDA, and an NVIDIA GPU with bfloat16
support and about 7 GB of free VRAM.

Generation is compiled with `torch.compile`. The first image takes an extra 30
to 45 seconds while it compiles; after that, an 832×1216 image takes about 10
seconds on an RTX 4090.

## ComfyUI

The repository is a ComfyUI custom-node folder. Download it into
`custom_nodes` and install its requirements:

```bash
cd ComfyUI/custom_nodes
hf download data-archetype/dflow_2b --local-dir dflow_2b
pip install -r dflow_2b/requirements.txt
```

To update later, run the same `hf download` command again. The manual explains
how to [install an older release](MANUAL.md#updating-and-older-versions).

Load `dflow_2b/comfyui/workflows/dflow_default.json`, or drag any image from the
[gallery](GALLERY.md) onto the canvas to get the workflow that made it. Start
ComfyUI with `--preview-method auto` for live previews.

## Python

```bash
hf download data-archetype/dflow_2b --local-dir dflow_2b
pip install -e dflow_2b
```

```python
from dflow.inference import GenerationSettings
from dflow.pipeline import DFlowPipeline

pipe = DFlowPipeline.from_pretrained("dflow_2b")
image = pipe("A lighthouse on a cliff at dusk.", GenerationSettings(seed=7)).images[0]
image.save("lighthouse.png", pnginfo=pipe.png_info(image))
```

`from_pretrained` also takes the Hub id `data-archetype/dflow_2b`, in which case
the files go to the Hugging Face cache. If you have diffusers installed, a thin
diffusers-style wrapper is available as
`dflow.diffusers_pipeline.DFlowDiffusersPipeline`.

## Prompts

Write captions the way you would describe a photo or a painting: the subject,
the setting, the light and the medium. Long prompts are fine, up to 6,144
tokens.

Put text you want in the image in double quotes, as in
`A shop sign that reads "OPEN LATE"`. The model reads quoted text letter by
letter, which helps with spelling.

A layout describes the picture as a whole and then lists its elements, each
with a label, a caption and a box `[y0, x0, y1, x1]` on a 0–1000 scale. Text
elements carry the exact string to render:

```json
{"summary": {"canvas": "single",
             "caption": "A travel poster of a mountain above a lake."},
 "frame": {"caption": "The peak sits in the upper middle.",
           "palette": ["#F3E6C8", "#2F5D62"]},
 "items": [
   {"label": "object", "caption": "A snow-capped mountain.",
    "box_2d": [250, 180, 620, 820]},
   {"label": "text", "caption": "The title in tall serif capitals.",
    "text": "SILVER LAKE", "box_2d": [120, 110, 220, 890]}]}
```

Use it as the prompt in Python, or paste it into the DFlow Layout Encode node.
MOSS-Image layout prompts and editable drafts go in the same places.
The [manual](MANUAL.md#json-layouts) covers every field and works through a
full poster.

## Limitations

- It is a preview, and quality varies from prompt to prompt and seed to seed.
- Hands and anatomy often go wrong.
- Small text and long passages of text are hit and miss.
- Above about one megapixel results get less reliable. For large images, move
  the [self-attention gain](MANUAL.md#self-attention-gain) towards 0.
- Styles far from photography and classical art are weaker.

You are responsible for how you use the model and its outputs.

## Licence

- The weights, the `dflow` package, the documentation and the gallery images:
  ModelGo Attribution-NonCommercial 2.0 (`MG-BY-NC-2.0`). See
  [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE).
- `comfyui/` and the root `__init__.py`: GPL-3.0. See
  [`comfyui/LICENSE`](comfyui/LICENSE).
- `text_encoder/`: Gemma is provided under and subject to the Gemma Terms of Use
  found at [gemma.ai/resources/terms](https://gemma.ai/resources/terms). A copy
  is in [`text_encoder/LICENSE-GEMMA.md`](text_encoder/LICENSE-GEMMA.md).
- dinac3_96 has its own licence, in
  [its repository](https://huggingface.co/data-archetype/dinac3_96).

Third-party material is listed in [`ATTRIBUTION.md`](ATTRIBUTION.md).

## Citation

```bibtex
@misc{dflow_2b,
  title  = {dflow\_2b},
  author = {{Data Archetype}},
  year   = {2026},
  url    = {https://huggingface.co/data-archetype/dflow_2b},
  note   = {Preview release, version 0.22}
}
```