ReyChiaro commited on
Commit
833c4e9
·
verified ·
1 Parent(s): c356840

Upload weights

Browse files
.gitattributes CHANGED
@@ -1,35 +1 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.safetensors filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
MANIFEST.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 2,
3
+ "repository": "ReyChiaro/MaskFlow",
4
+ "base_model": "Qwen/Qwen-Image-Edit-2511",
5
+ "format": "diffusers-peft-lora-safetensors",
6
+ "adapter_names": {
7
+ "sft": "maskflow",
8
+ "dmd": "dmd"
9
+ },
10
+ "weights": [
11
+ {
12
+ "filename": "maskflow-S.safetensors",
13
+ "variant": "S",
14
+ "role": "sft",
15
+ "size_bytes": 1510070696,
16
+ "sha256": "abde09d33238e6b2133a4a7dd86b9830ef93a8d97978e5ba437d60675c75dafd",
17
+ "rank": 256,
18
+ "alpha": 256,
19
+ "recommended_num_inference_steps": 50,
20
+ "recommended_text_cfg_scale": 4.0
21
+ },
22
+ {
23
+ "filename": "maskflow-S-tcfg4-step8.safetensors",
24
+ "variant": "S distilled 8-step",
25
+ "role": "dmd",
26
+ "requires": "maskflow-S.safetensors",
27
+ "size_bytes": 1510070656,
28
+ "sha256": "109580b294c3993984303fa39cb1dc77dfc90fc892075e90d85d1afd079a49e7",
29
+ "rank": 256,
30
+ "alpha": 256,
31
+ "recommended_num_inference_steps": 8,
32
+ "recommended_text_cfg_scale": 4.0
33
+ },
34
+ {
35
+ "filename": "maskflow-S-tcfg4-step16.safetensors",
36
+ "variant": "S distilled 16-step",
37
+ "role": "dmd",
38
+ "requires": "maskflow-S.safetensors",
39
+ "size_bytes": 1510070656,
40
+ "sha256": "e9292a27cb68b8021d84cea8731ef656f2dcf0a8c66f57a577e7591dd03f0b10",
41
+ "rank": 256,
42
+ "alpha": 256,
43
+ "recommended_num_inference_steps": 16,
44
+ "recommended_text_cfg_scale": 4.0
45
+ },
46
+ {
47
+ "filename": "maskflow-SEC.safetensors",
48
+ "variant": "SEC",
49
+ "role": "sft",
50
+ "size_bytes": 1510070656,
51
+ "sha256": "972a2e54547474aaf3cb284f17395445bfba427b56da22b1efbbeea6dbc5fcdf",
52
+ "rank": 256,
53
+ "alpha": 256,
54
+ "recommended_num_inference_steps": 50,
55
+ "recommended_text_cfg_scale": 4.0
56
+ },
57
+ {
58
+ "filename": "maskflow-SEC-tcfg4-step16.safetensors",
59
+ "variant": "SEC distilled 16-step",
60
+ "role": "dmd",
61
+ "requires": "maskflow-SEC.safetensors",
62
+ "size_bytes": 1510070656,
63
+ "sha256": "4af5c87f43a892e5ac07c080e4bc67b3ee88e576371e6255c1132902ebf4646f",
64
+ "rank": 256,
65
+ "alpha": 256,
66
+ "recommended_num_inference_steps": 16,
67
+ "recommended_text_cfg_scale": 4.0
68
+ },
69
+ {
70
+ "filename": "maskflow-SEC-tcfg4-step8.safetensors",
71
+ "variant": "SEC distilled 8-step",
72
+ "role": "dmd",
73
+ "requires": "maskflow-SEC.safetensors",
74
+ "size_bytes": 1510070656,
75
+ "sha256": "157b9f869457b790160099cf3c5d4fbe44d5c46739a3ae49b1fb7abeda5fda1c",
76
+ "rank": 256,
77
+ "alpha": 256,
78
+ "recommended_num_inference_steps": 8,
79
+ "recommended_text_cfg_scale": 4.0
80
+ }
81
+ ]
82
+ }
README.md CHANGED
@@ -1,3 +1,167 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ library_name: diffusers
4
+ pipeline_tag: image-to-image
5
+ base_model: Qwen/Qwen-Image-Edit-2511
6
+ datasets:
7
+ - ReyChiaro/MaskEdit-10k
8
+ tags:
9
+ - image-editing
10
+ - regional-image-editing
11
+ - mask-guided-image-editing
12
+ - qwen-image
13
+ - lora
14
+ - diffusers
15
+ inference: false
16
  ---
17
+
18
+ <img src="https://raw.githubusercontent.com/ReyChiaro/MaskFlow/main/assets/readme/maskflow-header.svg" width="100%" alt="MaskFlow" />
19
+
20
+ # 🌊 MaskFlow: Precise, Consistent and Seamless Regional Image Editing
21
+
22
+ <p align="center">
23
+ <a href="https://reychiaro.github.io/MaskFlow"><img src="https://img.shields.io/badge/Project_Page-7C3AED?logo=googlechrome&amp;logoColor=white" alt="Project Page" /></a>
24
+ <a href="https://arxiv.org/abs/2608.06929"><img src="https://img.shields.io/badge/arXiv-Paper-751D38?logo=arxiv&amp;logoColor=white" alt="arXiv Paper" /></a>
25
+ <a href="https://github.com/ReyChiaro/MaskFlow"><img src="https://img.shields.io/badge/GitHub-Code-E38DA7?logo=github&amp;logoColor=white" alt="GitHub Code" /></a>
26
+ <a href="https://huggingface.co/ReyChiaro/MaskFlow"><img src="https://img.shields.io/badge/Hugging_Face-Model-EFD046?logo=huggingface&amp;logoColor=white" alt="Hugging Face Model" /></a>
27
+ <a href="https://huggingface.co/datasets/ReyChiaro/MaskEdit-10k"><img src="https://img.shields.io/badge/Hugging_Face-Dataset-EFD046?logo=huggingface&amp;logoColor=white" alt="Hugging Face Dataset" /></a>
28
+ <a href="https://github.com/ModelTC/LightX2V"><img src="https://img.shields.io/badge/LightX2V-Demo-67A7E8?logo=github&amp;logoColor=white" alt="LightX2V Demo" /></a>
29
+ </p>
30
+
31
+ MaskFlow is a mask-based framework for precise regional image editing. Given a source image, a spatial mask, and a text instruction, it edits the selected region while preserving the surrounding content. Its localized generation process and Soft-Poisson refinement improve regional control, background consistency, and boundary quality.
32
+
33
+ These files are LoRA adapters for the base model [`Qwen/Qwen-Image-Edit-2511`](https://huggingface.co/Qwen/Qwen-Image-Edit-2511). The official MaskFlow pipeline is required for mask-conditioned editing and Soft-Poisson refinement, this model repository contains adapter weights rather than a standalone Diffusers pipeline.
34
+
35
+ ## Available weights
36
+
37
+ | File | Variant | Steps | Text CFG | Intended use |
38
+ |---|---|---:|---:|---|
39
+ | `maskflow-S.safetensors` | S | 50 | 4.0 | Standard checkpoint trained with `scene` |
40
+ | `maskflow-S-tcfg4-step8.safetensors` | S distilled | 8 | 4.0 | Faster inference |
41
+ | `maskflow-S-tcfg4-step16.safetensors` | S distilled | 16 | 4.0 | Faster inference |
42
+ | `maskflow-SEC.safetensors` | SEC | 50 | 4.0 | Standard checkpoint trained with `scene+infographics` |
43
+ | `maskflow-SEC-tcfg4-step8.safetensors` | SEC distilled | 8 | 4.0 | Faster inference |
44
+ | `maskflow-SEC-tcfg4-step16.safetensors` | SEC distilled | 16 | 4.0 | Faster inference |
45
+
46
+ > NOTE:
47
+ > - The variant `S` means that the model is trained with the `scene` split in [MaskEdit-10k](https://huggingface.co/datasets/ReyChiaro/MaskEdit-10k).
48
+ > - The variant `SEC` means that the model is trained with all splits in [MaskEdit-10k](https://huggingface.co/datasets/ReyChiaro/MaskEdit-10k).
49
+ > - A distilled LoRA is a residual adapter and must be used together with the matching standard SFT LoRA (`S` with `S`, or `SEC` with `SEC`). The SFT adapter is loaded as `maskflow`, while the distilled adapter is loaded as `dmd`.
50
+ > - Although the student is distilled with teacher text classifier-free guidance, we recommend enabling CFG during student inference for better performance.
51
+
52
+ <!-- The `S` and `SEC` identifiers follow the official release naming. All adapters use LoRA rank 256 and alpha 256. Exact file sizes and SHA-256 checksums are recorded in [`MANIFEST.json`](./MANIFEST.json). -->
53
+
54
+ ## Quick start
55
+
56
+ ### 1. Install the official code
57
+
58
+ MaskFlow requires Python 3.12 or later. An NVIDIA GPU is recommended.
59
+
60
+ ```bash
61
+ git clone https://github.com/ReyChiaro/MaskFlow.git
62
+ cd MaskFlow
63
+ python -m pip install uv
64
+ uv python install 3.12
65
+ uv sync
66
+ ```
67
+
68
+ ### 2. Prepare inputs
69
+
70
+ Prepare a source image and a spatially aligned mask. White pixels in the mask indicate the edit region; black pixels indicate the area to preserve.
71
+
72
+ ### 3. Run inference
73
+
74
+ No manual weight download is required. Diffusers downloads and caches the selected file on first use.
75
+
76
+ **Standard usage:** Load the standard trained LoRA into model using the following scripts
77
+
78
+ ```bash
79
+ uv run python inference.py \
80
+ input.source=/absolute/path/to/source.png \
81
+ input.mask=/absolute/path/to/mask.png \
82
+ 'input.prompt=Replace the masked object with a red ceramic vase.' \
83
+ checkpoint.sft_path=ReyChiaro/MaskFlow \
84
+ checkpoint.sft_weight_name=maskflow-S.safetensors \
85
+ runtime.num_inference_steps=50 \
86
+ runtime.text_cfg_scale=4.0 \
87
+ output.path=outputs/result.png
88
+ ```
89
+
90
+ **Distillation inference:** Load *both* SFT LoRA and distilled LoRA into model to enable less steps inference
91
+
92
+ ```bash
93
+ uv run python inference.py \
94
+ input.source=/absolute/path/to/source.png \
95
+ input.mask=/absolute/path/to/mask.png \
96
+ 'input.prompt=Replace the masked object with a red ceramic vase.' \
97
+ checkpoint.sft_path=ReyChiaro/MaskFlow \
98
+ checkpoint.sft_weight_name=maskflow-S.safetensors \
99
+ checkpoint.dmd_path=ReyChiaro/MaskFlow \
100
+ checkpoint.dmd_weight_name=maskflow-S.safetensors \
101
+ runtime.num_inference_steps=8 \
102
+ runtime.text_cfg_scale=4.0 \
103
+ output.path=outputs/result.png
104
+ ```
105
+
106
+ > We recommand enable student classifier-free guidance in distillation version to get better performance.
107
+
108
+ To use local files, pass each `.safetensors` path and leave its corresponding `weight_name` unset:
109
+
110
+ ```bash
111
+ checkpoint.sft_path=/absolute/path/to/maskflow-S.safetensors \
112
+ checkpoint.dmd_path=/absolute/path/to/maskflow-S-tcfg4-step8.safetensors
113
+ ```
114
+
115
+ ## Loading the LoRA adapter with Diffusers
116
+
117
+ The following snippet only demonstrates adapter loading. Use the official MaskFlow pipeline above for actual mask-guided editing.
118
+
119
+ ```python
120
+ import torch
121
+ from diffusers import QwenImageTransformer2DModel
122
+
123
+ transformer = QwenImageTransformer2DModel.from_pretrained(
124
+ "Qwen/Qwen-Image-Edit-2511",
125
+ subfolder="transformer",
126
+ torch_dtype=torch.bfloat16,
127
+ )
128
+ # Apply the standard SFT LoRA to the base transformer first.
129
+ transformer.load_lora_adapter(
130
+ "ReyChiaro/MaskFlow",
131
+ weight_name="maskflow-SEC.safetensors",
132
+ prefix=None,
133
+ adapter_name="maskflow",
134
+ )
135
+ transformer.set_adapter("maskflow")
136
+ transformer.fuse_lora(adapter_names=["maskflow"], safe_fusing=True)
137
+ transformer.unload_lora()
138
+
139
+ # The distilled LoRA is trained as a residual on top of the SFT model.
140
+ transformer.load_lora_adapter(
141
+ "ReyChiaro/MaskFlow",
142
+ weight_name="maskflow-SEC-tcfg4-step8.safetensors",
143
+ prefix=None,
144
+ adapter_name="dmd",
145
+ )
146
+ transformer.set_adapter("dmd")
147
+ ```
148
+
149
+ > More usage can refer to `inference.py`.
150
+
151
+ ## License
152
+
153
+ The MaskFlow adapter weights and repository materials are released under the MIT License. See [`LICENSE`](./LICENSE). Use of the base model is also subject to its own license and terms.
154
+
155
+ ## Citation
156
+
157
+ ```bibtex
158
+ @misc{xu2026maskflowpreciseconsistentseamless,
159
+ title={MaskFlow: Precise, Consistent and Seamless Regional Image Editing},
160
+ author={Rui Xu and Yang Yong and Shunzi Yang and Ruihao Gong and Chengtao Lv},
161
+ year={2026},
162
+ eprint={2608.06929},
163
+ archivePrefix={arXiv},
164
+ primaryClass={cs.CV},
165
+ url={https://arxiv.org/abs/2608.06929},
166
+ }
167
+ ```
maskflow-S-tcfg4-step16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9292a27cb68b8021d84cea8731ef656f2dcf0a8c66f57a577e7591dd03f0b10
3
+ size 1510070656
maskflow-S-tcfg4-step8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:109580b294c3993984303fa39cb1dc77dfc90fc892075e90d85d1afd079a49e7
3
+ size 1510070656
maskflow-S.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:abde09d33238e6b2133a4a7dd86b9830ef93a8d97978e5ba437d60675c75dafd
3
+ size 1510070696
maskflow-SEC-tcfg4-step16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4af5c87f43a892e5ac07c080e4bc67b3ee88e576371e6255c1132902ebf4646f
3
+ size 1510070656
maskflow-SEC-tcfg4-step8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:157b9f869457b790160099cf3c5d4fbe44d5c46739a3ae49b1fb7abeda5fda1c
3
+ size 1510070656
maskflow-SEC.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:972a2e54547474aaf3cb284f17395445bfba427b56da22b1efbbeea6dbc5fcdf
3
+ size 1510070656