RegionE: Adaptive Region-Aware Generation for Efficient Image Editing
Project description
RegionE: Adaptive Region-Aware Generation for Efficient Image Editing
🥳 What's New
- [2025/12/22] Release the PyPi Package.
- [2025/12/22] Release the code for Step1X-Edit-v1p2 and Qwen-Image-Edit-2509.
- [2025/10/29] 👋 Upload paper and init project. RegionE losslessly accelerates SOTA instruction-based image editing models, including Step1X-Edit, FLUX.1 Kontext, and Qwen-Image-Edit, achieving acceleration factors of 2.57×, 2.41×, and 2.06×.
🎥 Demo
https://github.com/user-attachments/assets/23cb6eda-6f2e-418d-8638-8de6c6aaf44d
🏃 Overview
RegionE is an adaptive, region-aware generation framework that accelerates instruction-based image editing tasks without additional training. Specifically, the RegionE framework consists of three main components: 1) Adaptive Region Partition. We observed that the trajectory of unedited regions is straight, allowing for multi-step denoised predictions to be inferred in a single step. Therefore, in the early denoising stages, we partition the image into edited and unedited regions based on the difference between the final estimated result and the reference image. 2) Region-Aware Generation. After distinguishing the regions, we replace multi-step denoising with one-step prediction for unedited areas. For edited regions, the trajectory is curved, requiring local iterative denoising. To improve the efficiency and quality of local iterative generation, we propose the Region-Instruction KV Cache, which reduces computational cost while incorporating global information. 3) Adaptive Velocity Decay Cache. Observing that adjacent timesteps in edited regions exhibit strong velocity similarity, we further propose an adaptive velocity decay cache to accelerate the local denoising process.
🛠️ Dependencies and Installation
Begin by cloning the repository:
git clone https://github.com/Peyton-Chen/RegionE.git
cd RegionE
We recommend CUDA versions 12.4 or 12.1 for the manual installation.
# 1. Create conda environment
conda create -n regione python==3.10.18
# 2. Activate the environment
conda activate regione
# 3. Install PyTorch and other dependencies using pip
# For CUDA 12.1
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu121
# For CUDA 12.4
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
# 4. Install pip dependencies
python -m pip install -r requirements.txt
# 5. Install the latest version of diffusers
pip install git+https://github.com/Peyton-Chen/diffusers.git@step1xedit_v1p2
# 6. Install flash attention v2 (optional)
python -m pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.8.2 --no-build-isolation
🎯 Quick Start
You can directly run the provided demo scripts under the scripts/ directory.
Alternatively, you can manually run the example command below:
Step1X-Edit [🤗Download Pretrained Model ]
python src/Step1X-Edit/main.py \
--model_path stepfun-ai/Step1X-Edit-v1p1-diffusers \
--num_inference_steps 28 \
--use_regione \
--warmup_step 6 \
--post_step 2 \
--refresh_step "16" \
--threshold 0.88 \
--cache_threshold 0.02 \
--erosion_dilation \
--guidance_scale 6.0 \
--seed 110 \
--device cuda \
--image_path assets/data.jsonl \
--output_dir result/Step1X-Edit/Demo/RegionE
FLUX.1 Kontext [🤗Download Pretrained Model ]
python src/FluxKontext/main.py \
--model_path black-forest-labs/FLUX.1-Kontext-dev \
--num_inference_steps 28 \
--use_regione \
--warmup_step 6 \
--post_step 2 \
--refresh_step "16" \
--threshold 0.93 \
--cache_threshold 0.01 \
--erosion_dilation \
--guidance_scale 2.5 \
--seed 110 \
--device cuda \
--image_path assets/data.jsonl \
--output_dir result/FluxKontext/Demo/RegionE
Qwen-Image-Edit [🤗Download Pretrained Model ]
python src/Qwen-Image/main.py \
--model_path Qwen/Qwen-Image-Edit \
--num_inference_steps 28 \
--use_regione \
--warmup_step 6 \
--post_step 2 \
--refresh_step "16" \
--threshold 0.80 \
--cache_threshold 0.03 \
--erosion_dilation \
--guidance_scale 4.0 \
--seed 110 \
--device cuda \
--image_path assets/data.jsonl \
--output_dir result/Qwen-Image/Demo/RegionE
📝 Evaluation
1. Load Benchmark
RegionE was evaluated on Kontext-Bench or GEdit-Bench, and the following is the script for obtaining the benchmark data.
bash script/load_data.sh
2. Batch Image Generation
For Step1X-Edit,
# Vanilla
python src/Step1X-Edit/main.py \
--model_path stepfun-ai/Step1X-Edit-v1p1-diffusers \
--num_inference_steps 28 \
--guidance_scale 6.0 \
--seed 110 \
--device cuda \
--evaluation \
--image_path data/Processed/GEdit-Bench/en \
--output_dir result/Step1X-Edit/Pretrain
# + RegionE
python src/Step1X-Edit/main.py \
--model_path stepfun-ai/Step1X-Edit-v1p1-diffusers \
--num_inference_steps 28 \
--use_regione \
--warmup_step 6 \
--post_step 2 \
--refresh_step "16" \
--threshold 0.88 \
--cache_threshold 0.02 \
--erosion_dilation \
--guidance_scale 6.0 \
--seed 110 \
--device cuda \
--evaluation \
--image_path data/Processed/GEdit-Bench/en \
--output_dir result/Step1X-Edit/RegionE
For FLUX.1 Kontext,
# Vanilla
python src/FluxKontext/main.py \
--model_path black-forest-labs/FLUX.1-Kontext-dev \
--num_inference_steps 28 \
--guidance_scale 2.5 \
--seed 110 \
--device cuda \
--evaluation \
--image_path data/Processed/Kontext-Bench \
--output_dir result/FluxKontext/Pretrain
# + RegionE
python src/FluxKontext/main.py \
--model_path black-forest-labs/FLUX.1-Kontext-dev \
--num_inference_steps 28 \
--use_regione \
--warmup_step 6 \
--post_step 2 \
--refresh_step "16" \
--threshold 0.93 \
--cache_threshold 0.04 \
--erosion_dilation \
--guidance_scale 2.5 \
--seed 110 \
--device cuda \
--evaluation \
--image_path data/Processed/Kontext-Bench \
--output_dir result/FluxKontext/RegionE
For Qwen-Image-Edit,
# Vanilla
python src/Qwen-Image/main.py \
--model_path Qwen/Qwen-Image-Edit \
--num_inference_steps 28 \
--guidance_scale 4.0 \
--seed 110 \
--device cuda \
--evaluation \
--image_path data/Processed/GEdit-Bench/en \
--output_dir result/Qwen-Image/Pretrain
# + RegionE
python src/Qwen-Image/main.py \
--model_path Qwen/Qwen-Image-Edit \
--num_inference_steps 28 \
--use_regione \
--warmup_step 6 \
--post_step 2 \
--refresh_step "16" \
--threshold 0.80 \
--cache_threshold 0.03 \
--erosion_dilation \
--guidance_scale 4.0 \
--seed 110 \
--device cuda \
--evaluation \
--image_path data/Processed/GEdit-Bench/en \
--output_dir result/Qwen-Image/RegionE
3. Metric Evaluation
The evaluation scripts for PSNR, SSIM and LPIPS are as follows:
python evaluation/metric_all_task.py \
--folder1 result/Step1X-Edit/Pretrain \
--folder2 result/Step1X-Edit/RegionE
The evaluation scripts for GPT4o-Score are as follows (please refer to EVAL):
cd evaluation/GEdit-Bench
python run_gedit_score.py \
--backbone="gpt4o" \
--instruction_language="en" \
--task_type="all" \
--edited_images_dir="../../result/Step1X-Edit/RegionE" \
--source_img_dir="../../data/Processed/GEdit-Bench/en" \
--model_name="RegionE"
The folder structure of this project should look like:
RegionE/
├── assets/
├── data/
│ ├── GEdit-Bench/
│ ├── Kontext-Bench/
│ ├── Processed/
│ └── preprocess.py
├── evaluation/
│ ├── GEdit-Bench/
│ ├── metric_all_task.py
│ └── merge_metric.py
├── src/
│ ├── Step1X-Edit/
│ │ ├── fused_kernels.py
│ │ ├── inplace.py
│ │ ├── main.py
│ │ └── utils.py
│ ├── Qwen-Image/
│ └── FluxKontext/
├── result/
│ ├── Step1X-Edit/
│ │ ├── RegionE/
│ │ │ ├── background_change/
│ │ │ │ ├── generation/
│ │ │ │ │ ├── 0f385bcff859231789a9c978cafecc2a.png
│ │ │ │ │ ├── 1e6d1fa7e02689ee2409aa686132cab1.png
│ │ │ │ └── └── ...
│ │ │ ├── color_alter/
│ │ │ ├── material_alter/
│ │ │ └── ...
│ │ └── Pretrain/
│ ├── Qwen-Image/
│ └── FluxKontext/
├── script/
├── requirements.txt
└── README.md
💫 Acknowledgments
We thank the following excellent open-source works: Step1X-Edit, FLUX.1 Kontext, Qwen-Image and RAS.
🔗 Citation
@article{chen2025regione,
title = {RegionE: Adaptive Region-Aware Generation for Efficient Image Editing},
author = {Pengtao Chen and Xianfang Zeng and Maosen Zhao and Mingzhu Shen and Peng Ye and Bangyin Xiang and Zhibo Wang and Wei Cheng and Gang Yu and Tao Chen},
journal = {arXiv preprint arXiv:2510.25590},
year = {2025}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file regione-0.1.0.tar.gz.
File metadata
- Download URL: regione-0.1.0.tar.gz
- Upload date:
- Size: 82.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30b2b9a85984a7158bbb01c314906279eddf86791c08fcd43316902972eed880
|
|
| MD5 |
a7c820d02bf1232fbfece2f74efd422f
|
|
| BLAKE2b-256 |
13ea0b4128243122e4001332f057510dd3de4b81533d353097427eb079e74b49
|
Provenance
The following attestation bundles were made for regione-0.1.0.tar.gz:
Publisher:
python-publish.yml on Peyton-Chen/RegionE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
regione-0.1.0.tar.gz -
Subject digest:
30b2b9a85984a7158bbb01c314906279eddf86791c08fcd43316902972eed880 - Sigstore transparency entry: 777756137
- Sigstore integration time:
-
Permalink:
Peyton-Chen/RegionE@508c8ce67b57efeb18f7d0644e7c978c2e0e150a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Peyton-Chen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@508c8ce67b57efeb18f7d0644e7c978c2e0e150a -
Trigger Event:
release
-
Statement type:
File details
Details for the file regione-0.1.0-py3-none-any.whl.
File metadata
- Download URL: regione-0.1.0-py3-none-any.whl
- Upload date:
- Size: 85.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc682422714f7825322b123151e577a767c69f2f7c9ee535b5b2484a1d91d2ec
|
|
| MD5 |
e1a4479cd619a60af4e785c3f510d29d
|
|
| BLAKE2b-256 |
6c302d39edf59cd9f166f1e0fa42c8620b7e1447df03a4a97779b0dad1bae5d3
|
Provenance
The following attestation bundles were made for regione-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on Peyton-Chen/RegionE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
regione-0.1.0-py3-none-any.whl -
Subject digest:
dc682422714f7825322b123151e577a767c69f2f7c9ee535b5b2484a1d91d2ec - Sigstore transparency entry: 777756142
- Sigstore integration time:
-
Permalink:
Peyton-Chen/RegionE@508c8ce67b57efeb18f7d0644e7c978c2e0e150a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Peyton-Chen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@508c8ce67b57efeb18f7d0644e7c978c2e0e150a -
Trigger Event:
release
-
Statement type: