EditMGT Model for HuggingFace Transformers

This repository contains a HuggingFace Transformers-compatible implementation of the EditMGT model for image editing based on text instructions.

Installation

pip install transformers pillow
# Install other required dependencies from the original EditMGT repository

Usage

from eval.utils import init_edit_mgt
from src.v2_model import negative_prompt
from PIL import Image

# Initialize the pipeline
pipe = init_edit_mgt(
    ckpt_path='./runs/editmgt-ct/checkpoint',
    enable_fp16=False,
    device='cuda:0',
    use_ema=False
)

# Load your image
reference_image = Image.open("your_image.jpg").resize((1024, 1024))

# Generate edited image
result = pipe(
    prompt=["Make the sky more blue and add clouds"],
    negative_prompt=[negative_prompt],
    height=1024,
    width=1024,
    num_inference_steps=36,
    guidance_scale=6,
    num_images_per_prompt=1,
    reference_image=[reference_image],
    reference_strength=1.1,
)

# Save the result
result.images[0].save("edited_image.png")

Citation

If you use this model, please cite the original work:

@article{editmgt2023,
  title={EditMGT: Text-guided Image Editing with Masked Generative Transformer},
  author={...},
  journal={...},
  year={2023}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for WeiChow/EditMGT

Base model

google/gemma-2-2b
Finetuned
(724)
this model

Dataset used to train WeiChow/EditMGT