Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionImg2ImgPipeline
|
3 |
+
import torch
|
4 |
+
import base64
|
5 |
+
|
6 |
+
model = StableDiffusionImg2ImgPipeline.from_pretrained(
|
7 |
+
"black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.float16
|
8 |
+
).to("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
+
|
10 |
+
def transform_image(image, prompt="place it"):
|
11 |
+
result = model(prompt=prompt, image=image).images[0]
|
12 |
+
return result
|
13 |
+
|
14 |
+
gr.Interface(
|
15 |
+
fn=transform_image,
|
16 |
+
inputs=[gr.Image(type="pil"), gr.Textbox(label="Prompt", value="place it")],
|
17 |
+
outputs=gr.Image(type="pil", label="Modified Image"),
|
18 |
+
title="Image Overlay with LoRA"
|
19 |
+
).launch()
|