MLL76
/

MLL76 rrui commited on
Commit
b7d6f3e
·
0 Parent(s):

Duplicate from GD-ML/FLUX-Text

Browse files

Co-authored-by: lan <rrui@users.noreply.huggingface.co>

Files changed (44) hide show
  1. .gitattributes +59 -0
  2. README.md +341 -0
  3. assets/comfyui.png +3 -0
  4. assets/comfyui2.png +3 -0
  5. assets/flux-text.png +3 -0
  6. assets/gradio_1.png +3 -0
  7. assets/gradio_2.png +3 -0
  8. assets/hint.png +0 -0
  9. assets/hint1.png +0 -0
  10. assets/hint2.png +0 -0
  11. assets/hint_imgs.jpg +0 -0
  12. assets/hint_imgs1.jpg +0 -0
  13. assets/hint_imgs2.jpg +0 -0
  14. assets/hint_imgs_word.png +0 -0
  15. assets/hint_imgs_word1.png +0 -0
  16. assets/hint_imgs_word2.png +0 -0
  17. assets/method.png +3 -0
  18. assets/method_result.png +3 -0
  19. assets/new_img1.png +3 -0
  20. assets/new_img2.png +3 -0
  21. assets/ori_img1.png +3 -0
  22. assets/ori_img2.png +3 -0
  23. assets/video1.gif +3 -0
  24. assets/video2.gif +3 -0
  25. assets/video_end1.png +3 -0
  26. assets/video_end2.png +3 -0
  27. data_text_recog_glyph/Art/data-info.json +0 -0
  28. data_text_recog_glyph/COCO_Text/data-info.json +0 -0
  29. data_text_recog_glyph/LSVT/data-info.json +3 -0
  30. data_text_recog_glyph/MTWI2018/data-info.json +3 -0
  31. data_text_recog_glyph/ReCTS/data-info.json +3 -0
  32. data_text_recog_glyph/icdar2017rctw/data-info.json +0 -0
  33. data_text_recog_glyph/laion/data_v1.1-info.json +3 -0
  34. data_text_recog_glyph/mlt2019/data-info.json +0 -0
  35. data_text_recog_glyph/wukong_1of5/data_v1.1-info.json +3 -0
  36. data_text_recog_glyph/wukong_2of5/data_v1.1-info.json +3 -0
  37. data_text_recog_glyph/wukong_3of5/data_v1.1-info.json +3 -0
  38. data_text_recog_glyph/wukong_4of5/data_v1.1-info.json +3 -0
  39. data_text_recog_glyph/wukong_5of5/data_v1.1-info.json +3 -0
  40. epoch_100.pt +3 -0
  41. model_512/config.yaml +46 -0
  42. model_512/pytorch_lora_weights.safetensors +3 -0
  43. model_multisize/config.yaml +59 -0
  44. model_multisize/pytorch_lora_weights.safetensors +3 -0
.gitattributes ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/comfyui.png filter=lfs diff=lfs merge=lfs -text
37
+ assets/comfyui2.png filter=lfs diff=lfs merge=lfs -text
38
+ assets/flux-text.png filter=lfs diff=lfs merge=lfs -text
39
+ assets/gradio_1.png filter=lfs diff=lfs merge=lfs -text
40
+ assets/gradio_2.png filter=lfs diff=lfs merge=lfs -text
41
+ assets/method.png filter=lfs diff=lfs merge=lfs -text
42
+ assets/method_result.png filter=lfs diff=lfs merge=lfs -text
43
+ assets/new_img1.png filter=lfs diff=lfs merge=lfs -text
44
+ assets/new_img2.png filter=lfs diff=lfs merge=lfs -text
45
+ assets/ori_img1.png filter=lfs diff=lfs merge=lfs -text
46
+ assets/ori_img2.png filter=lfs diff=lfs merge=lfs -text
47
+ assets/video1.gif filter=lfs diff=lfs merge=lfs -text
48
+ assets/video2.gif filter=lfs diff=lfs merge=lfs -text
49
+ assets/video_end1.png filter=lfs diff=lfs merge=lfs -text
50
+ assets/video_end2.png filter=lfs diff=lfs merge=lfs -text
51
+ data_text_recog_glyph/LSVT/data-info.json filter=lfs diff=lfs merge=lfs -text
52
+ data_text_recog_glyph/MTWI2018/data-info.json filter=lfs diff=lfs merge=lfs -text
53
+ data_text_recog_glyph/ReCTS/data-info.json filter=lfs diff=lfs merge=lfs -text
54
+ data_text_recog_glyph/laion/data_v1.1-info.json filter=lfs diff=lfs merge=lfs -text
55
+ data_text_recog_glyph/wukong_1of5/data_v1.1-info.json filter=lfs diff=lfs merge=lfs -text
56
+ data_text_recog_glyph/wukong_2of5/data_v1.1-info.json filter=lfs diff=lfs merge=lfs -text
57
+ data_text_recog_glyph/wukong_3of5/data_v1.1-info.json filter=lfs diff=lfs merge=lfs -text
58
+ data_text_recog_glyph/wukong_4of5/data_v1.1-info.json filter=lfs diff=lfs merge=lfs -text
59
+ data_text_recog_glyph/wukong_5of5/data_v1.1-info.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: image-to-image
4
+ library_name: diffusers
5
+ tags:
6
+ - text-editing
7
+ - multilingual
8
+ - diffusion-transformer
9
+ - diffusion-model
10
+ ---
11
+
12
+ # FLUX-Text: A Simple and Advanced Diffusion Transformer Baseline for Scene Text Editing
13
+
14
+ <a href='https://amap-ml.github.io/FLUX-text/'><img src='https://img.shields.io/badge/Project-Page-green'></a>
15
+ <a href='https://arxiv.org/abs/2505.03329'><img src='https://img.shields.io/badge/Technique-Report-red'></a>
16
+ <a href="https://github.com/AMAP-ML/FluxText"><img src="https://img.shields.io/badge/GitHub-Code-blue.svg?logo=github&"></a>
17
+ <a href="https://huggingface.co/GD-ML/FLUX-Text/"><img src="https://img.shields.io/badge/%F0%9F%A4%97_HuggingFace-Model-ffbd45.svg" alt="HuggingFace"></a>
18
+
19
+ > *[Rui Lan](https://scholar.google.com/citations?user=zwVlWXwAAAAJ&hl=zh-CN), [Yancheng Bai](https://scholar.google.com/citations?hl=zh-CN&user=Ilx8WNkAAAAJ&view_op=list_works&sortby=pubdate), [Xu Duan](https://scholar.google.com/citations?hl=zh-CN&user=EEUiFbwAAAAJ), [Mingxing Li](https://scholar.google.com/citations?hl=zh-CN&user=-pfkprkAAAAJ), [Lei Sun](https://allylei.github.io), [Xiangxiang Chu](https://scholar.google.com/citations?hl=zh-CN&user=jn21pUsAAAAJ&view_op=list_works&sortby=pubdate)*
20
+ > <br>
21
+ > ALibaba Group
22
+
23
+ <img src='assets/flux-text.png'>
24
+
25
+ ## 📖 Overview
26
+ * **Motivation:** Scene text editing is a challenging task that aims to modify or add text in images while maintaining the fidelity of newly generated text and visual coherence with the background. The main challenge of this task is that we need to edit multiple line texts with diverse language attributes (e.g., fonts, sizes, and styles), language types (e.g., English, Chinese), and visual scenarios (e.g., poster, advertising, gaming).
27
+ * **Contribution:** We propose FLUX-Text, a novel text editing framework for editing multi-line texts in complex visual scenes. By incorporating a lightweight Condition Injection LoRA module, Regional text perceptual loss, and two-stage training strategy, we significantly significant improvements on both Chinese and English benchmarks.
28
+ <img src='assets/method.png'>
29
+
30
+ ## News
31
+
32
+ - **2025-07-16**: 🔥 Update comfyui node. We have decoupled the FLUX-Text node to support the use of more basic nodes. Due to differences in node computation in ComfyUI, if you need more consistent results, you should set min_length to 512 in the [code](https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/text_encoders/flux.py#L12).
33
+
34
+ <div align="center">
35
+ <table>
36
+ <tr>
37
+ <td><img src="assets/comfyui2.png" alt="workflow/FLUX-Text-Basic-Workflow.json" width="400"/></td>
38
+ </tr>
39
+ <tr>
40
+ <td align="center">workflow/FLUX-Text-Basic-Workflow.json</td>
41
+ </tr>
42
+ </table>
43
+ </div>
44
+
45
+ - **2025-07-13**: 🔥 The training code has been updated. The code now supports multi-scale training.
46
+
47
+ - **2025-07-13**: 🔥 Update the low-VRAM version of the Gradio demo, which It currently requires 25GB of VRAM to run. Looking forward to more efficient, lower-memory solutions from the community.
48
+
49
+ - **2025-07-08**: 🔥 ComfyUI Node is supported! You can now build an workflow based on FLUX-Text for editing posters. It is definitely worth trying to set up a workflow to automatically enhance product image service information and service scope. Meanwhile, utilizing the first and last frames enables the creation of video data with text effects. Thanks to the [community work](https://github.com/AMAP-ML/FluxText/issues/4), FLUX-Text was run on 8GB VRAM.
50
+
51
+ <div align="center">
52
+ <table>
53
+ <tr>
54
+ <td><img src="assets/comfyui.png" alt="workflow/FLUX-Text-Workflow.json" width="400"/></td>
55
+ </tr>
56
+ <tr>
57
+ <td align="center">workflow/FLUX-Text-Workflow.json</td>
58
+ </tr>
59
+ </table>
60
+ </div>
61
+
62
+ <div align="center">
63
+ <table>
64
+ <tr>
65
+ <td><img src="assets/ori_img1.png" alt="assets/ori_img1.png" width="200"/></td>
66
+ <td><img src="assets/new_img1.png" alt="assets/new_img1.png" width="200"/></td>
67
+ <td><img src="assets/ori_img2.png" alt="assets/ori_img2.png" width="200"/></td>
68
+ <td><img src="assets/new_img2.png" alt="assets/new_img2.png" width="200"/></td>
69
+ </tr>
70
+ <tr>
71
+ <td align="center">original image</td>
72
+ <td align="center">edited image</td>
73
+ <td align="center">original image</td>
74
+ <td align="center">edited image</td>
75
+ </tr>
76
+ </table>
77
+ </div>
78
+
79
+ <div align="center">
80
+ <table>
81
+ <tr>
82
+ <td><img src="assets/video_end1.png" alt="assets/video_end1.png" width="400"/></td>
83
+ <td><img src="assets/video1.gif" alt="assets/video1.gif" width="400"/></td>
84
+ </tr>
85
+ <tr>
86
+ <td><img src="assets/video_end2.png" alt="assets/video_end2.png" width="400"/></td>
87
+ <td><img src="assets/video2.gif" alt="assets/video2.gif" width="400"/></td>
88
+ </tr>
89
+ <tr>
90
+ <td align="center">last frame</td>
91
+ <td align="center">video</td>
92
+ </tr>
93
+ </table>
94
+ </div>
95
+
96
+ - **2025-07-04**: 🔥 We have released gradio demo! You can now try out FLUX-Text.
97
+
98
+ <div align="center">
99
+ <table>
100
+ <tr>
101
+ <td><img src="assets/gradio_1.png" alt="Example 1" width="400"/></td>
102
+ <td><img src="assets/gradio_2.png" alt="Example 2" width="400"/></td>
103
+ </tr>
104
+ <tr>
105
+ <td align="center">Example 1</td>
106
+ <td align="center">Example 2</td>
107
+ </tr>
108
+ </table>
109
+ </div>
110
+
111
+ - **2025-07-03**: 🔥 We have released our [pre-trained checkpoints](https://huggingface.co/GD-ML/FLUX-Text/) on Hugging Face! You can now try out FLUX-Text with the official weights.
112
+
113
+ - **2025-06-26**: ⭐️ Inference and evaluate code are released. Once we have ensured that everything is functioning correctly, the new model will be merged into this repository.
114
+
115
+ ## Todo List
116
+ 1. - [x] Inference code
117
+ 2. - [x] Pre-trained weights
118
+ 3. - [x] Gradio demo
119
+ 4. - [x] ComfyUI
120
+ 5. - [x] Training code
121
+
122
+ ## 🛠️ Installation
123
+
124
+ We recommend using Python 3.10 and PyTorch with CUDA support. To set up the environment:
125
+
126
+ ```bash
127
+ # Create a new conda environment
128
+ conda create -n flux_text python=3.10
129
+ conda activate flux_text
130
+
131
+ # Install other dependencies
132
+ pip install -r requirements.txt
133
+ pip install flash_attn --no-build-isolation
134
+ pip install Pillow==9.5.0
135
+ ```
136
+
137
+ ## 🤗 Model Introduction
138
+
139
+ FLUX-Text is an open-source version of the scene text editing model. FLUX-Text can be used for editing posters, emotions, and more. The table below displays the list of text editing models we currently offer, along with their foundational information.
140
+
141
+ <table style="border-collapse: collapse; width: 100%;">
142
+ <tr>
143
+ <th style="text-align: center;">Model Name</th>
144
+ <th style="text-align: center;">Image Resolution</th>
145
+ <th style="text-align: center;">Memory Usage</th>
146
+ <th style="text-align: center;">English Sen.Acc</th>
147
+ <th style="text-align: center;">Chinese Sen.Acc</th>
148
+ <th style="text-align: center;">Download Link</th>
149
+ </tr>
150
+ <tr>
151
+ <th style="text-align: center;">FLUX-Text-512</th>
152
+ <th style="text-align: center;">512*512</th>
153
+ <th style="text-align: center;">34G</th>
154
+ <th style="text-align: center;">0.8419</th>
155
+ <th style="text-align: center;">0.7132</th>
156
+ <th style="text-align: center;"><a href="https://huggingface.co/GD-ML/FLUX-Text/tree/main/model_512">🤗 HuggingFace</a></th>
157
+ </tr>
158
+ <tr>
159
+ <th style="text-align: center;">FLUX-Text</th>
160
+ <th style="text-align: center;">Multi Resolution</th>
161
+ <th style="text-align: center;">34G for (512*512)</th>
162
+ <th style="text-align: center;">0.8228</th>
163
+ <th style="text-align: center;">0.7161</th>
164
+ <th style="text-align: center;"><a href="https://huggingface.co/GD-ML/FLUX-Text/tree/main/model_multisize">🤗 HuggingFace</a></th>
165
+ </tr>
166
+ </table>
167
+
168
+ ## 🔥 ComfyUI
169
+
170
+ <details close>
171
+ <summary> Installing via GitHub </summary>
172
+
173
+ First, install and set up [ComfyUI](https://github.com/comfyanonymous/ComfyUI), and then follow these steps:
174
+
175
+ 1. **Clone FLUXText Repository**:
176
+ ```shell
177
+ git clone https://github.com/AMAP-ML/FluxText.git
178
+ ```
179
+
180
+ 2. **Install FluxText**:
181
+ ```shell
182
+ cd FluxText && pip install -r requirements.txt
183
+ ```
184
+
185
+ 3. **Integrate FluxText Comfy Nodes with ComfyUI**:
186
+ - **Symbolic Link (Recommended)**:
187
+ ```shell
188
+ ln -s $(pwd)/ComfyUI-fluxtext path/to/ComfyUI/custom_nodes/
189
+ ```
190
+ - **Copy Directory**:
191
+ ```shell
192
+ cp -r ComfyUI-fluxtext path/to/ComfyUI/custom_nodes/
193
+ ```
194
+
195
+ </details>
196
+
197
+ ## 🔥 Quick Start
198
+
199
+ Here's a basic example of using FLUX-Text:
200
+
201
+ ```python
202
+ import numpy as np
203
+ from PIL import Image
204
+ import torch
205
+ import yaml
206
+
207
+ from src.flux.condition import Condition
208
+ from src.flux.generate_fill import generate_fill
209
+ from src.train.model import OminiModelFIll
210
+ from safetensors.torch import load_file
211
+
212
+ config_path = ""
213
+ lora_path = ""
214
+ with open(config_path, "r") as f:
215
+ config = yaml.safe_load(f)
216
+ model = OminiModelFIll(
217
+ flux_pipe_id=config["flux_path"],
218
+ lora_config=config["train"]["lora_config"],
219
+ device=f"cuda",
220
+ dtype=getattr(torch, config["dtype"]),
221
+ optimizer_config=config["train"]["optimizer"],
222
+ model_config=config.get("model", {}),
223
+ gradient_checkpointing=True,
224
+ byt5_encoder_config=None,
225
+ )
226
+
227
+ state_dict = load_file(lora_path)
228
+ state_dict_new = {x.replace('lora_A', 'lora_A.default').replace('lora_B', 'lora_B.default').replace('transformer.', ''): v for x, v in state_dict.items()}
229
+ model.transformer.load_state_dict(state_dict_new, strict=False)
230
+ pipe = model.flux_pipe
231
+
232
+ prompt = "lepto college of education, the written materials on the picture: LESOTHO , COLLEGE OF , RE BONA LESELI LESEL , EDUCATION ."
233
+ hint = Image.open("assets/hint.png").resize((512, 512)).convert('RGB')
234
+ img = Image.open("assets/hint_imgs.jpg").resize((512, 512))
235
+ condition_img = Image.open("assets/hint_imgs_word.png").resize((512, 512)).convert('RGB')
236
+ hint = np.array(hint) / 255
237
+ condition_img = np.array(condition_img)
238
+ condition_img = (255 - condition_img) / 255
239
+ condition_img = [condition_img, hint, img]
240
+ position_delta = [0, 0]
241
+ condition = Condition(
242
+ condition_type='word_fill',
243
+ condition=condition_img,
244
+ position_delta=position_delta,
245
+ )
246
+ generator = torch.Generator(device="cuda")
247
+ res = generate_fill(
248
+ pipe,
249
+ prompt=prompt,
250
+ conditions=[condition],
251
+ height=512,
252
+ width=512,
253
+ generator=generator,
254
+ model_config=config.get("model", {}),
255
+ default_lora=True,
256
+ )
257
+ res.images[0].save('flux_fill.png')
258
+ ```
259
+
260
+ ## 🤗 gradio
261
+
262
+ You can upload the glyph image and mask image to edit text region. Or you can use `manual edit` to obtain glyph image and mask image.
263
+
264
+ first, download the model weight and config in [HuggingFace](https://huggingface.co/GD-ML/FLUX-Text)
265
+
266
+ ```bash
267
+ python app.py --model_path xx.safetensors --config_path config.yaml
268
+ ```
269
+
270
+ ## 💪🏻 Training
271
+
272
+ 1. Download training dataset [**AnyWord-3M**](https://modelscope.cn/datasets/iic/AnyWord-3M/summary) from ModelScope, unzip all \*.zip files in each subfolder, then open *\*.json* and modify the `data_root` with your own path of *imgs* folder for each sub dataset.
273
+
274
+ 2. Replace the old annotations in AnyWord with the new [annotations](https://huggingface.co/GD-ML/FLUX-Text/tree/main/data_text_recog_glyph). Change the dataset annotations path and image_root in [src/train/data_word.py](https://github.com/AMAP-ML/FluxText/blob/main/src/train/data_word.py#L538).
275
+
276
+ ```python
277
+ json_paths = [
278
+ ['dataset/Anyword/data_text_recog_glyph/Art/data-info.json', 'AnyWord-3M/ocr_data/Art/imgs/'],
279
+ ['dataset/Anyword/data_text_recog_glyph/COCO_Text/data-info.json', 'AnyWord-3M/ocr_data/COCO_Text/imgs/'],
280
+ ['dataset/Anyword/data_text_recog_glyph/icdar2017rctw/data-info.json', 'AnyWord-3M/ocr_data/icdar2017rctw/imgs'],
281
+ ['dataset/Anyword/data_text_recog_glyph/LSVT/data-info.json', 'AnyWord-3M/ocr_data/LSVT/imgs'],
282
+ ['dataset/Anyword/data_text_recog_glyph/mlt2019/data-info.json', 'AnyWord-3M/ocr_data/mlt2019/imgs/'],
283
+ ['dataset/Anyword/data_text_recog_glyph/MTWI2018/data-info.json', 'AnyWord-3M/ocr_data/MTWI2018/imgs'],
284
+ ['dataset/Anyword/data_text_recog_glyph/ReCTS/data-info.json', 'AnyWord-3M/ocr_data/ReCTS/imgs'],
285
+ ['dataset/Anyword/data_text_recog_glyph/laion/data_v1.1-info.json', 'AnyWord-3M/laion/imgs'],
286
+ ['dataset/Anyword/data_text_recog_glyph/wukong_1of5/data_v1.1-info.json', 'AnyWord-3M/wukong_1of5/imgs'],
287
+ ['dataset/Anyword/data_text_recog_glyph/wukong_2of5/data_v1.1-info.json', 'AnyWord-3M/wukong_2of5/imgs'],
288
+ ['dataset/Anyword/data_text_recog_glyph/wukong_3of5/data_v1.1-info.json', 'AnyWord-3M/wukong_3of5/imgs'],
289
+ ['dataset/Anyword/data_text_recog_glyph/wukong_4of5/data_v1.1-info.json', 'AnyWord-3M/wukong_4of5/imgs'],
290
+ ['dataset/Anyword/data_text_recog_glyph/wukong_5of5/data_v1.1-info.json', 'AnyWord-3M/wukong_5of5/imgs'],
291
+ ]
292
+ ```
293
+
294
+ 3. Download the ODM weights in [HuggingFace](https://huggingface.co/GD-ML/FLUX-Text/blob/main/epoch_100.pt) and change `odm_loss/modelpath` in the [config file](https://github.com/AMAP-ML/FluxText/blob/main/train/config/word_multi_size.yaml#L60).
295
+
296
+ 3. (Optional) Download the pretrained weight in [HuggingFace](https://huggingface.co/GD-ML/FLUX-Text) and change `reuse_lora_path` in the [config file](https://github.com/AMAP-ML/FluxText/blob/main/train/config/word_multi_size.yaml#L44).
297
+
298
+ 4. Run the training scripts. With 48GB of VRAM, you can train at 512×512 resolution with a batch size of 2 in LoRA rank 8.
299
+
300
+ ```bash
301
+ bash train/script/train_word.sh
302
+ ```
303
+
304
+
305
+ ## 📊 Evaluation
306
+
307
+ For [Anytext-benchmark](https://modelscope.cn/datasets/iic/AnyText-benchmark/summary), please set the **config_path**, **model_path**, **json_path**, **output_dir** in the `eval/gen_imgs_anytext.sh` and generate the text editing results.
308
+
309
+ ```bash
310
+ bash eval/gen_imgs_anytext.sh
311
+ ```
312
+
313
+ For `Sen.ACC, NED, FID and LPIPS` evaluation, use the scripts in the `eval` folder.
314
+
315
+ ```bash
316
+ bash eval/eval_ocr.sh
317
+ bash eval/eval_fid.sh
318
+ bash eval/eval_lpips.sh
319
+ ```
320
+
321
+ ## 📈 Results
322
+
323
+ <img src='assets/method_result.png'>
324
+
325
+ ## 🌹 Acknowledgement
326
+
327
+ Our work is primarily based on [OminiControl](https://github.com/Yuanshi9815/OminiControl), [AnyText](https://github.com/tyxsspa/AnyText), [Open-Sora](https://github.com/hpcaitech/Open-Sora), [Phantom](https://github.com/Phantom-video/Phantom). We are sincerely grateful for their excellent works.
328
+
329
+ ## 📚 Citation
330
+
331
+ If you find our paper and code helpful for your research, please consider starring our repository ⭐ and citing our work ✏️.
332
+ ```bibtex
333
+ @misc{lan2025fluxtext,
334
+ title={FLUX-Text: A Simple and Advanced Diffusion Transformer Baseline for Scene Text Editing},
335
+ author={Rui Lan and Yancheng Bai and Xu Duan and Mingxing Li and Lei Sun and Xiangxiang Chu},
336
+ year={2025},
337
+ eprint={2505.03329},
338
+ archivePrefix={arXiv},
339
+ primaryClass={cs.CV}
340
+ }
341
+ ```
assets/comfyui.png ADDED

Git LFS Details

  • SHA256: 722d8baef919f885470250d01fb322e25a40170d5f066dab408bde9b43222d1e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.65 MB
assets/comfyui2.png ADDED

Git LFS Details

  • SHA256: bf568344d296aec9e5f2672a3fbf98adaddfe9c872bf21e7695e4b48a85655fd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.96 MB
assets/flux-text.png ADDED

Git LFS Details

  • SHA256: 72a0ddcfd63483fb0ca11517192b78324f59b9d0f4c369a660bf75ce73de2e80
  • Pointer size: 133 Bytes
  • Size of remote file: 10.1 MB
assets/gradio_1.png ADDED

Git LFS Details

  • SHA256: 144311a2f1d82d773f196c177d8b381c33698a1f365aad0c2b4059297e690349
  • Pointer size: 132 Bytes
  • Size of remote file: 2.37 MB
assets/gradio_2.png ADDED

Git LFS Details

  • SHA256: 816a13d4e10e94c14d5729b10b1a785fd8a8fb94dba5078d25030ae4122bacca
  • Pointer size: 132 Bytes
  • Size of remote file: 1.14 MB
assets/hint.png ADDED
assets/hint1.png ADDED
assets/hint2.png ADDED
assets/hint_imgs.jpg ADDED
assets/hint_imgs1.jpg ADDED
assets/hint_imgs2.jpg ADDED
assets/hint_imgs_word.png ADDED
assets/hint_imgs_word1.png ADDED
assets/hint_imgs_word2.png ADDED
assets/method.png ADDED

Git LFS Details

  • SHA256: 06cf65d0f55764f5dcb5b017738f8c4bb7c83cdb4f1a0fca8ea1091c5123f83f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.16 MB
assets/method_result.png ADDED

Git LFS Details

  • SHA256: 52847b6df75de741f252d1e47a269a958b41af9686ca8464c3d6d5646d511dc6
  • Pointer size: 131 Bytes
  • Size of remote file: 395 kB
assets/new_img1.png ADDED

Git LFS Details

  • SHA256: 56255c96c300c2f7da95234e1ad5ef10194fef2608cbb79e475747edd73b833b
  • Pointer size: 131 Bytes
  • Size of remote file: 612 kB
assets/new_img2.png ADDED

Git LFS Details

  • SHA256: 94fd932e5fe902898f26773d60bf4ce582e2eeb2efe2893c305a6b3d6fc11b5c
  • Pointer size: 131 Bytes
  • Size of remote file: 427 kB
assets/ori_img1.png ADDED

Git LFS Details

  • SHA256: 49978502989564fe8ad02321a173bd96144ce3c11db6ec54e3f315a12848b9d1
  • Pointer size: 131 Bytes
  • Size of remote file: 710 kB
assets/ori_img2.png ADDED

Git LFS Details

  • SHA256: 05d55516b09063dfea12e20a1b3f4e6c888bd26c8d66688c3f4eb69b62c5c21c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.65 MB
assets/video1.gif ADDED

Git LFS Details

  • SHA256: 4205b11706d91ed4824ebd11806232e5531be9f8b3ecb9208ce3e6ad019c8a81
  • Pointer size: 132 Bytes
  • Size of remote file: 2.68 MB
assets/video2.gif ADDED

Git LFS Details

  • SHA256: 173a0842f1f3e0710651014744f573183a656895d31a33b23c8813a1dac6c8fc
  • Pointer size: 132 Bytes
  • Size of remote file: 1.18 MB
assets/video_end1.png ADDED

Git LFS Details

  • SHA256: 0007264768ba24078ca823f3e735467d23350f774f8f6e6b33ff5ff35ee4bbb5
  • Pointer size: 131 Bytes
  • Size of remote file: 954 kB
assets/video_end2.png ADDED

Git LFS Details

  • SHA256: 6de39544a6fd00d27c772774d925dde2559b44dba8723feff220a166a96c0692
  • Pointer size: 131 Bytes
  • Size of remote file: 695 kB
data_text_recog_glyph/Art/data-info.json ADDED
The diff for this file is too large to render. See raw diff
 
data_text_recog_glyph/COCO_Text/data-info.json ADDED
The diff for this file is too large to render. See raw diff
 
data_text_recog_glyph/LSVT/data-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7726b7363dab7fb21115f783d65a8bfe07a8c8b76baa24ec610829206fc51228
3
+ size 20801296
data_text_recog_glyph/MTWI2018/data-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3e881d778c748958f36436b23a96c980eb83c4348aa9ebae18db0e1f9d55fad
3
+ size 13882645
data_text_recog_glyph/ReCTS/data-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2142af01b48018c7c3e3312813725bf03e94b644cc7f185cff5ba219e09e0730
3
+ size 13331324
data_text_recog_glyph/icdar2017rctw/data-info.json ADDED
The diff for this file is too large to render. See raw diff
 
data_text_recog_glyph/laion/data_v1.1-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9470e4fd811ab66d4daece81bab598ebab90780cb6bf38a333844859347733ec
3
+ size 2153011640
data_text_recog_glyph/mlt2019/data-info.json ADDED
The diff for this file is too large to render. See raw diff
 
data_text_recog_glyph/wukong_1of5/data_v1.1-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e8f61d75e1d9dea8c29bb646872c52adc59b12f3c904750c25bbf930496c44f9
3
+ size 445006180
data_text_recog_glyph/wukong_2of5/data_v1.1-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb2a5b58f11eb8ba18cdce2c52743748ccc240dadb81a8b4885b9d156a58fe2d
3
+ size 460941784
data_text_recog_glyph/wukong_3of5/data_v1.1-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f86ed77a21e1c4ee0f08f0891064408ea9bd628508dc3033d313c35e629efa23
3
+ size 448771446
data_text_recog_glyph/wukong_4of5/data_v1.1-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbd35b03ec9c4812bbee9e84c05f9d34d1812aca5cdb0dc3af9cf301e8455c50
3
+ size 459732972
data_text_recog_glyph/wukong_5of5/data_v1.1-info.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d2c0ed58bb69a3a01f783c25fdefc82a9f30ff2798143f4a7cc5cb021098c8f
3
+ size 380928592
epoch_100.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7e329c97cae19e4fd3ad1b5867036952477dd09e53b90f39b2c68b100060156
3
+ size 709732641
model_512/config.yaml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dtype: bfloat16
2
+ flux_path: black-forest-labs/FLUX.1-Fill-dev
3
+ model:
4
+ add_cond_attn: false
5
+ latent_lora: false
6
+ union_cond_attn: true
7
+ model_type: flux_fill
8
+ train:
9
+ accumulate_grad_batches: 2
10
+ batch_size: 8
11
+ condition_type: word_fill
12
+ dataloader_workers: 4
13
+ dataset:
14
+ condition_size: 512
15
+ drop_image_prob: 0.1
16
+ drop_text_prob: 0.1
17
+ image_size: 512
18
+ padding: 8
19
+ target_size: 512
20
+ type: word
21
+ gradient_checkpointing: true
22
+ lora_config:
23
+ init_lora_weights: gaussian
24
+ lora_alpha: 256
25
+ r: 256
26
+ target_modules: (.*x_embedder|.*(?<!single_)transformer_blocks\.[0-9]+\.norm1\.linear|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_k|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_q|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_v|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_out\.0|.*(?<!single_)transformer_blocks\.[0-9]+\.ff\.net\.2|.*single_transformer_blocks\.[0-9]+\.norm\.linear|.*single_transformer_blocks\.[0-9]+\.proj_mlp|.*single_transformer_blocks\.[0-9]+\.proj_out|.*single_transformer_blocks\.[0-9]+\.attn.to_k|.*single_transformer_blocks\.[0-9]+\.attn.to_q|.*single_transformer_blocks\.[0-9]+\.attn.to_v|.*single_transformer_blocks\.[0-9]+\.attn.to_out)
27
+ max_steps: -1
28
+ odm_loss:
29
+ input_resolution: 512
30
+ modelpath: epoch_100.pt
31
+ w_loss_1: 30
32
+ w_loss_2: 30
33
+ w_loss_3: 30
34
+ w_loss_4: 30
35
+ w_loss_f: 1
36
+ optimizer:
37
+ params:
38
+ lr: 1
39
+ safeguard_warmup: true
40
+ use_bias_correction: true
41
+ weight_decay: 0.01
42
+ type: Prodigy
43
+ reuse_lora_path: reuse.safetensors
44
+ sample_interval: 2000
45
+ save_interval: 1000
46
+ save_path: output_dir
model_512/pytorch_lora_weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa64171deccf048f402a572fc6682c0c6cce7c5c462b559093cb906912e67d98
3
+ size 1854698344
model_multisize/config.yaml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dtype: bfloat16
2
+ flux_path: black-forest-labs/FLUX.1-Fill-dev
3
+ model:
4
+ add_cond_attn: false
5
+ attn_mask: false
6
+ latent_lora: false
7
+ mask_para:
8
+ base_ratio: 0.6
9
+ union_cond_attn: true
10
+ use_byt5_mask: false
11
+ model_type: flux_fill
12
+ train:
13
+ accumulate_grad_batches: 4
14
+ bucket_config:
15
+ 1024px:
16
+ 1:
17
+ - 1.0
18
+ - 2
19
+ 512px:
20
+ 1:
21
+ - 1.0
22
+ - 8
23
+ 768px:
24
+ 1:
25
+ - 1.0
26
+ - 4
27
+ condition_type: word_fill
28
+ dataloader_workers: 5
29
+ dataset:
30
+ drop_image_prob: 0.1
31
+ drop_text_prob: 0.1
32
+ glyph_scale: 1
33
+ random_select: true
34
+ type: word
35
+ gradient_checkpointing: true
36
+ lora_config:
37
+ init_lora_weights: gaussian
38
+ lora_alpha: 256
39
+ r: 256
40
+ target_modules: (.*x_embedder|.*(?<!single_)transformer_blocks\.[0-9]+\.norm1\.linear|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_k|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_q|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_v|.*(?<!single_)transformer_blocks\.[0-9]+\.attn\.to_out\.0|.*(?<!single_)transformer_blocks\.[0-9]+\.ff\.net\.2|.*single_transformer_blocks\.[0-9]+\.norm\.linear|.*single_transformer_blocks\.[0-9]+\.proj_mlp|.*single_transformer_blocks\.[0-9]+\.proj_out|.*single_transformer_blocks\.[0-9]+\.attn.to_k|.*single_transformer_blocks\.[0-9]+\.attn.to_q|.*single_transformer_blocks\.[0-9]+\.attn.to_v|.*single_transformer_blocks\.[0-9]+\.attn.to_out)
41
+ max_steps: -1
42
+ odm_loss:
43
+ modelpath: epoch_100.pt
44
+ w_loss_1: 20
45
+ w_loss_2: 20
46
+ w_loss_3: 20
47
+ w_loss_4: 20
48
+ w_loss_f: 1
49
+ optimizer:
50
+ params:
51
+ lr: 1
52
+ safeguard_warmup: true
53
+ use_bias_correction: true
54
+ weight_decay: 0.01
55
+ type: Prodigy
56
+ reuse_lora_path: reuse.safetensors
57
+ sample_interval: 2000
58
+ save_interval: 1000
59
+ save_path: output_dir
model_multisize/pytorch_lora_weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b92c90b4b5f0c63951f24089b454a5abb3b90cd99b49c89461f9bf92605358d
3
+ size 1854698344