Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,34 @@
|
|
| 1 |
-
import gradio as
|
| 2 |
import torch
|
| 3 |
-
from
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
-
# Model ကို
|
| 7 |
model_id = "Qwen/Qwen-Image-Edit-2509"
|
| 8 |
-
pipe =
|
| 9 |
pipe.to("cuda")
|
| 10 |
|
| 11 |
def edit_image(input_image, prompt):
|
| 12 |
if input_image is None or not prompt:
|
| 13 |
return None
|
| 14 |
|
| 15 |
-
# Model သို့ ပုံနှင့်
|
| 16 |
-
# (Model Card ပါ Parameter တည်ဆောက်ပုံအတိုင်း လိုအပ်သလို ညှိနှိုင်းပေးပါ)
|
| 17 |
output = pipe(image=input_image, prompt=prompt).images[0]
|
| 18 |
return output
|
| 19 |
|
| 20 |
# Gradio Interface တည်ဆောက်ခြင်း
|
| 21 |
-
with
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
-
with
|
| 26 |
-
with
|
| 27 |
-
image_input =
|
| 28 |
-
prompt_input =
|
| 29 |
-
submit_btn =
|
| 30 |
|
| 31 |
-
with
|
| 32 |
-
image_output =
|
| 33 |
|
| 34 |
submit_btn.click(
|
| 35 |
fn=edit_image,
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from diffusers import QwenImageEditPlusPipeline
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
+
# Model ကို loading လုပ်ခြင်း (Qwen-Image-Edit-2509 အတွက် bfloat16 သို့မဟုတ် float16 သုံးနိုင်သည်)
|
| 7 |
model_id = "Qwen/Qwen-Image-Edit-2509"
|
| 8 |
+
pipe = QwenImageEditPlusPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
|
| 9 |
pipe.to("cuda")
|
| 10 |
|
| 11 |
def edit_image(input_image, prompt):
|
| 12 |
if input_image is None or not prompt:
|
| 13 |
return None
|
| 14 |
|
| 15 |
+
# Model သို့ ပုံနှင့် Prompt ပေးပို့ခြင်း
|
|
|
|
| 16 |
output = pipe(image=input_image, prompt=prompt).images[0]
|
| 17 |
return output
|
| 18 |
|
| 19 |
# Gradio Interface တည်ဆောက်ခြင်း
|
| 20 |
+
with gr.Blocks() as demo:
|
| 21 |
+
gr.Markdown("# 🎨 Qwen-Image-Edit-2509 AI Editor")
|
| 22 |
+
gr.Markdown("Natural Language အသုံးပြုပြီး မိမိစိတ်ကြိုက် ပုံများကို ပြုပြင်ပြောင်းလဲလိုက်ပါ။")
|
| 23 |
|
| 24 |
+
with gr.Row():
|
| 25 |
+
with ui_col := gr.Column():
|
| 26 |
+
image_input = gr.Image(type="pil", label="မူရင်းပုံတင်ရန်")
|
| 27 |
+
prompt_input = gr.Textbox(lines=2, placeholder="ဥပမာ - Change the background to a sunny beach...", label="လုပ်ဆောင်စေလိုသည့် ညွှန်ကြားချက် (Prompt)")
|
| 28 |
+
submit_btn = gr.Button("ပုံပြောင်းလဲမည်", variant="primary")
|
| 29 |
|
| 30 |
+
with ui_col2 := gr.Column():
|
| 31 |
+
image_output = gr.Image(type="pil", label="ရလဒ်ပုံစံ")
|
| 32 |
|
| 33 |
submit_btn.click(
|
| 34 |
fn=edit_image,
|