File size: 7,356 Bytes
562d66f
4510bdc
562d66f
 
 
 
 
 
 
 
 
 
 
 
 
 
4510bdc
 
 
 
 
 
 
 
 
 
 
 
 
2518f09
 
4510bdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f7668f9
 
 
 
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
---
license: apache-2.0
pipeline_tag: text-to-image
tags:
- text-to-image
- image-to-image
- image-editing
- text-rendering
- flow-matching
- dit
- dc-ae
language:
- en
base_model:
- rootxhacker/HobbyLM-Image
---

# HobbyLM-image-2

**Try it in the browser: [🎨 HobbyLM Image 2 Space](https://huggingface.co/spaces/rootxhacker/HobbyLM-Image-2)** — generate, edit and spell, no setup.

Latest checkpoint of hobbylm-image-2. It does three things from one set of weights:

1. **Text-to-image** at 512px and 768px.
2. **Instruction editing** at 512px: give it an image and an instruction such as "make the car blue".
3. **Text rendering** at 512px: words in double quotes in the prompt are drawn into the image.

All sample images below are first-seed outputs with no selection.

I post trained my previous version of Image Generation model to build HobbyLM-Image-2

## Model

- **Size:** 333M-parameter flow-matching DiT with a small text-fusion module.
- **Text encoders (not included):** `openai/clip-vit-large-patch14` (64 tokens) and `google/flan-t5-large` (96 tokens).
- **Autoencoder (not included):** `mit-han-lab/dc-ae-f32c32-sana-1.1-diffusers` (32x compression, 32 channels).
- **Tasks:** the DiT takes a task id. 0 is text-to-image on one panel. 1 is editing on two panels, `[noisy target | source image]`. 2 is text rendering on two panels, `[noisy target | glyph panel]`, where the glyph panel is the requested words in a plain font on white.

## Text-to-image

768px, Euler 50 steps, CFG 4.5, timestep shift 1.5 (stored in the checkpoint).

![Text-to-image samples](samples/text_to_image_768u.jpg)

![More text-to-image samples](samples/text_to_image_768u_2.jpg)

## Instruction editing

Each pair is a 512px image generated by the model (left) and the same model's edit of it (right). Text guidance 7.5, image guidance 1.2.

![Editing samples](samples/editing_768u.jpg)

Ten of these twelve edits are clean. "Add a croissant beside the cup" replaced the cup, and "change the background to a beach" changed the ground but kept the buildings.

## Text rendering

512px. The quoted words are placed in the glyph panel one word per line around the image centre.

![Mixed samples: plain prompts and prompts with text](samples/mixed_768u.jpg)

![Text rendering on scene prompts](samples/text_rendering_768u.jpg)

The second grid shows the limits: bold print on flat surfaces (shirts, road signs, book covers) is usually right, while neon, chalk, handwriting and words of seven or more letters are often misspelled. Without the glyph panel the model cannot spell.

## Usage

```python
from PIL import Image
from hobby_image.inference import HobbyImage

m = HobbyImage("model_v2_768u.pt")

# text-to-image (768px)
m.generate(["a red fox sitting in a snowy forest, golden hour light, photo"])[0].save("fox.jpg")

# instruction editing (any aspect ratio in, same size out)
m.edit([Image.open("fox.jpg")], ["make it autumn"])[0].save("fox_autumn.jpg")

# text rendering (words in double quotes)
m.text(['a wooden sign that says "OPEN" hanging on a cafe door'])[0].save("open.jpg")
```

Command line:

```bash
python -m hobby_image.inference --ckpt model_v2_768u.pt --prompt "a lighthouse on a cliff at sunset" --out out.jpg
python -m hobby_image.inference --ckpt model_v2_768u.pt --image in.jpg --prompt "make the car blue" --out edit.jpg
python -m hobby_image.inference --ckpt model_v2_768u.pt --text --prompt 'a road sign that says "NEXT EXIT"' --out sign.jpg
```

Requires `torch`, `diffusers>=0.32`, `transformers`, `sentencepiece` and `pillow`. `samples/inference_check.jpg` is the output of this script run end to end (generate, crop to a wide image, edit, text).

## ComfyUI

`comfyui/ComfyUI-HobbyLM-Image/` is a custom-node pack with four nodes: Loader, Generate, Edit and Text.

1. Copy the folder to `ComfyUI/custom_nodes/ComfyUI-HobbyLM-Image` and install its `requirements.txt`.
2. Put `model_v2_768u.pt` in `ComfyUI/models/hobbylm/`.
3. Restart ComfyUI. The nodes are under **HobbyLM-Image**, and `example_workflows/` has three workflows in API format.

These are wrapper nodes that run the model's own sampler; they do not connect to KSampler, CLIP Text Encode or VAE Decode. Their outputs are standard ComfyUI images. The pack was run in ComfyUI 0.46.0 through the `/prompt` endpoint: all three example workflows completed, and their outputs are below (text-to-image, edit source, edit result, glyph panel, text result). It was not tested by hand in the browser interface.

![ComfyUI outputs](samples/comfyui_check.jpg)

## Scores (self-run, one seed)

| Benchmark | `model_v2_768` | `model_v2_768u` |
|---|---|---|
| GenEval 2 Soft-TIFA at 768px, GM / AM | 15.99 / 59.55 | 15.92 / 61.06 |
| GEdit-Bench-EN, Qwen2.5-VL-72B judge, SC / PQ / O | no editing | 6.03 / 6.00 / 5.35 |
| Text benchmark, all words spelled right | cannot spell | 74% |

- **GenEval 2:** 800 prompts, Qwen3-VL-8B judge, official code. Differences under about 2 GM are noise.
- **GEdit-Bench-EN:** all 606 English edits, official VIEScore prompts, judge served with vLLM. The same setup scores the released Step1X-Edit v1.0 outputs at 7.43 / 7.25 / 7.01 against a published 7.39 / 7.28 / 7.07. Sources are padded to a square, edited at 512px and cropped back.
- **Text benchmark:** 100 prompts of my own (40 one-word, 40 two-word, 20 three-word texts on signs, shirts, mugs, posters and similar), read back by Qwen3-VL-8B. 74% have every requested word spelled correctly and 68% match exactly with no stray text. It is not a published benchmark, and scene-heavy prompts do worse (about half correct).
- **Emu Edit test set** (previous checkpoint `model_v2_768t`, 500 edits): CLIP-dir 0.090, CLIP-im 0.859, L1 0.120, DINO 0.787. InstructPix2Pix through the same code scores 0.075 / 0.852 / 0.123 / 0.772.

### Against other sub-1B models

Published numbers from each model's own paper or model card; generation settings differ, and the GenEval 2 hobby baselines are self-reported at 256px.

![Sub-1B models on GenEval](samples/geneval_sub1b.png)

![Sub-1B models on GenEval 2](samples/geneval2_sub1b.png)

## Files

- `model_v2_768u.pt`: current EMA weights, all three tasks. Keys: `sd` (DiT), `fusion` (text fusion), `cfg_dict`, `lat_std`, `sf`, `steps`, `v2` (metadata, including the timestep shifts).
- `model_v2_768.pt`: the 23 November checkpoint, text-to-image only.
- `hobby_image/inference.py`: the three entry points shown above.
- `hobby_image/dit.py`, `hobby_image/v2.py`, `hobby_image/glyph.py`: model, text conditioning and glyph panel code.
- `comfyui/ComfyUI-HobbyLM-Image/`: ComfyUI custom nodes, with their own copy of the `hobby_image` code.
- `samples/`: the grids on this page, plus `text_benchmark_768u.jpg` (twelve images from the text benchmark).

## Known weaknesses

- Faces smaller than about 100px, hands, and wide laughing mouths.
- Editing follows the instruction less reliably than large editors (GEdit-Bench overall 5.35 against about 7 for Step1X-Edit). Changing text inside an image, style transfer and motion changes are the weakest edit types.
- The editor and the text mode are square, 512px only. Non-square edit inputs are padded.
- Text rendering needs the glyph panel and works for one to three short words.
- Counts above three people.

## Credits

I would not be possible to train this model without credits from Modal.com