Rahul-KJS commited on
Commit
86b3ea8
·
verified ·
1 Parent(s): 793f602

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import QwenImageEditPipeline
3
+ from PIL import Image
4
+ import torch
5
+
6
+ # Load the pipeline
7
+ pipe = QwenImageEditPipeline.from_pretrained("Qwen/Qwen-Image-Edit").to("cuda")
8
+
9
+ def edit_image(image, prompt):
10
+ result = pipe(
11
+ image=image,
12
+ prompt=prompt,
13
+ num_inference_steps=30,
14
+ generator=torch.manual_seed(0),
15
+ ).images[0]
16
+ return result
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("## 🖼️ Qwen Image Edit Demo")
20
+ with gr.Row():
21
+ with gr.Column():
22
+ input_image = gr.Image(type="pil")
23
+ prompt = gr.Textbox(label="Edit instruction")
24
+ btn = gr.Button("Generate")
25
+ with gr.Column():
26
+ output_image = gr.Image(type="pil")
27
+
28
+ btn.click(fn=edit_image, inputs=[input_image, prompt], outputs=output_image)
29
+
30
+ demo.launch()