Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import DiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
# Base + LoRA
|
| 7 |
+
BASE_MODEL = "Qwen/Qwen-Image-Edit-2509"
|
| 8 |
+
LORA_PATH = "dx8152/Qwen-Image-Edit-2509-Light_restoration"
|
| 9 |
+
|
| 10 |
+
pipe = DiffusionPipeline.from_pretrained(BASE_MODEL, torch_dtype=torch.float16).to("cuda")
|
| 11 |
+
pipe.load_lora_weights(LORA_PATH)
|
| 12 |
+
|
| 13 |
+
def edit_image(prompt, input_image):
|
| 14 |
+
result = pipe(prompt=prompt, image=input_image).images[0]
|
| 15 |
+
return result
|
| 16 |
+
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=edit_image,
|
| 19 |
+
inputs=[gr.Textbox(label="Prompt"), gr.Image(label="Input Image")],
|
| 20 |
+
outputs=gr.Image(label="Output Image"),
|
| 21 |
+
title="Qwen Image Edit – Light Restoration"
|
| 22 |
+
)
|
| 23 |
+
demo.launch()
|