Views
No views yet

1git clone https://github.com/weichow23/editmgt
2cd editmgt1# Create and activate conda environment
2conda create --name editmgt python=3.9.2
3conda activate editmgt
4
5# Optional: Install system dependencies
6sudo apt-get install libgl1-mesa-glx libglib2.0-0 -y
7
8# Install Python dependencies
9pip3 install git+https://github.com/openai/CLIP
10pip3 install -r requirements.txteditmgt directory:1import os
2import sys
3sys.path.append("./")
4from PIL import Image
5from src.editmgt import init_edit_mgt
6from src.v2_model import negative_prompt
7
8if __name__ == "__main__":
9 pipe = init_edit_mgt(device='cuda:0')
10 # Forcing the use of bf16 can improve speed, but it will incur a performance penalty.
11 # We noticed that GEditBench dropped by about 0.8.
12 # pipe = init_edit_mgt(device, enable_bf16=False)
13
14 # pipe.local_guidance=0.01 # After starting, it will use the local GS auxiliary mode.
15 # pipe.local_query_text = 'owl' # Use specific words as attention queries
16 # pipe.attention_enable_blocks = [i for i in range(28, 37)] # attention layer used
17 input_image = Image.open('assets/case_5.jspg')
18 result = pipe(
19 prompt=['Make it into Ghibli style'],
20 height=1024,
21 width=1024,
22 num_inference_steps=36, # For some simple tasks, 16 steps are enough!
23 guidance_scale=6,
24 reference_strength=1.1,
25 reference_image=[input_image.resize((1024, 1024))],
26 negative_prompt=negative_prompt or None,
27 )
28 output_dir = "./output"
29 os.makedirs(output_dir, exist_ok=True)
30
31 file_path = os.path.join(output_dir, f"edited_case_5.png")
32 w, h = input_image.size
33 result.images[0].resize((w, h)).save(file_path)1@article{chow2025editmgt,
2 title={EditMGT: Unleashing Potentials of Masked Generative Transformers in Image Editing},
3 author={Chow, Wei and Li, Linfeng and Kong, Lingdong and Li, Zefeng and Xu, Qi and Song, Hang and Ye, Tian and Wang, Xian and Bai, Jinbin and Xu, Shilin and others},
4 journal={arXiv preprint arXiv:2512.11715},
5 year={2025}
6}