Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from diffusers import AutoPipelineForImage2Image
|
| 4 |
+
|
| 5 |
+
model_id = "PrithivMLmods/Qwen-Image-Edit-2511-LoRAs-Fast"
|
| 6 |
+
|
| 7 |
+
pipe = AutoPipelineForImage2Image.from_pretrained(
|
| 8 |
+
model_id,
|
| 9 |
+
torch_dtype=torch.float16
|
| 10 |
+
).to("cuda")
|
| 11 |
+
|
| 12 |
+
def edit(image, prompt):
|
| 13 |
+
w, h = image.size
|
| 14 |
+
image = image.resize((w, h))
|
| 15 |
+
|
| 16 |
+
result = pipe(
|
| 17 |
+
prompt=prompt,
|
| 18 |
+
image=image,
|
| 19 |
+
strength=0.65,
|
| 20 |
+
num_inference_steps=4 # FAST MODE
|
| 21 |
+
).images[0]
|
| 22 |
+
|
| 23 |
+
return result
|
| 24 |
+
|
| 25 |
+
gr.Interface(
|
| 26 |
+
fn=edit,
|
| 27 |
+
inputs=[
|
| 28 |
+
gr.Image(type="pil"),
|
| 29 |
+
gr.Textbox(label="Prompt edit")
|
| 30 |
+
],
|
| 31 |
+
outputs="image",
|
| 32 |
+
title="My AI Image Editor (4 Steps Fast)"
|
| 33 |
+
).launch()
|