File size: 840 Bytes
86b3ea8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from diffusers import QwenImageEditPipeline
from PIL import Image
import torch

# Load the pipeline
pipe = QwenImageEditPipeline.from_pretrained("Qwen/Qwen-Image-Edit").to("cuda")

def edit_image(image, prompt):
    result = pipe(
        image=image,
        prompt=prompt,
        num_inference_steps=30,
        generator=torch.manual_seed(0),
    ).images[0]
    return result

with gr.Blocks() as demo:
    gr.Markdown("## 🖼️ Qwen Image Edit Demo")
    with gr.Row():
        with gr.Column():
            input_image = gr.Image(type="pil")
            prompt = gr.Textbox(label="Edit instruction")
            btn = gr.Button("Generate")
        with gr.Column():
            output_image = gr.Image(type="pil")

    btn.click(fn=edit_image, inputs=[input_image, prompt], outputs=output_image)

demo.launch()