nayminsan commited on
Commit
e58df4c
·
verified ·
1 Parent(s): 846bc46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -1,35 +1,34 @@
1
- import gradio as ui
2
  import torch
3
- from pipeline_qwen import QwenImageEditPipeline # Hugging Face Model ရဲ့ တရားဝင် Pipeline ခေါ်ယူပုံအတိုင်း ပြောင်းလဲပေးရန်လိုအပ်နိုင်သည်
4
  from PIL import Image
5
 
6
- # Model ကို GPUေါင်ပြီLoad ခြင်
7
  model_id = "Qwen/Qwen-Image-Edit-2509"
8
- pipe = QwenImageEditPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
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 သို့ ပုံနှင့် Text Instruction ပေးပို့ပြီး Edit လုပ်ခြင်း
16
- # (Model Card ပါ Parameter တည်ဆောက်ပုံအတိုင်း လိုအပ်သလို ညှိနှိုင်းပေးပါ)
17
  output = pipe(image=input_image, prompt=prompt).images[0]
18
  return output
19
 
20
  # Gradio Interface တည်ဆောက်ခြင်း
21
- with ui.Blocks() as demo:
22
- ui.Markdown("# 🎨 Qwen-Image-Edit-2509 AI Editor")
23
- ui.Markdown("Natural Language အသုံးပြုပြီး မိမိစိတ်ကြိုက် ပုံများကို ပြုပြင်ပြောင်းလဲလိုက်ပါ။")
24
 
25
- with ui.Row():
26
- with ui.Column():
27
- image_input = ui.Image(type="pil", label="မူရင်းပုံတင်ရန်")
28
- prompt_input = ui.Textbox(lines=2, placeholder="ဥပမာ - Change the background to a sunny beach...", label="လုပ်ဆောင်စေလိုသည့် ညွှန်ကြားချက် (Prompt)")
29
- submit_btn = ui.Button("ပုံပြောင်းလဲမည်", variant="primary")
30
 
31
- with ui.Column():
32
- image_output = ui.Image(type="pil", label="ရလဒ်ပုံစံ")
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,