| import gradio as gr |
| import torch |
| from diffusers import QwenImageEditPlusPipeline |
| from PIL import Image |
|
|
| |
| model_id = "Qwen/Qwen-Image-Edit-2509" |
| pipe = QwenImageEditPlusPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) |
| pipe.to("cuda") |
|
|
| def edit_image(input_image, prompt): |
| if input_image is None or not prompt: |
| return None |
| |
| |
| output = pipe(image=input_image, prompt=prompt).images[0] |
| return output |
|
|
| |
| with gr.Blocks() as demo: |
| gr.Markdown("# 🎨 Qwen-Image-Edit-2509 AI Editor") |
| gr.Markdown("Natural Language အသုံးပြုပြီး မိမိစိတ်ကြိုက် ပုံများကို ပြုပြင်ပြောင်းလဲလိုက်ပါ။") |
| |
| with gr.Row(): |
| with ui_col := gr.Column(): |
| image_input = gr.Image(type="pil", label="မူရင်းပုံတင်ရန်") |
| prompt_input = gr.Textbox(lines=2, placeholder="ဥပမာ - Change the background to a sunny beach...", label="လုပ်ဆောင်စေလိုသည့် ညွှန်ကြားချက် (Prompt)") |
| submit_btn = gr.Button("ပုံပြောင်းလဲမည်", variant="primary") |
| |
| with ui_col2 := gr.Column(): |
| image_output = gr.Image(type="pil", label="ရလဒ်ပုံစံ") |
| |
| submit_btn.click( |
| fn=edit_image, |
| inputs=[image_input, prompt_input], |
| outputs=image_output |
| ) |
|
|
| demo.launch() |