Spaces:
Runtime error
Runtime error
rajsecrets0
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
def merge_images(model_image, cloth_image):
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
"image_2": cloth_image,
|
12 |
-
}
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
|
17 |
-
#
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Create the Gradio interface
|
21 |
iface = gr.Interface(
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
+
from PIL import Image
|
5 |
|
6 |
+
# Load the pipeline
|
7 |
+
pipeline = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
|
8 |
|
9 |
def merge_images(model_image, cloth_image):
|
10 |
+
# Save uploaded images temporarily
|
11 |
+
model_image.save("model_image.png")
|
12 |
+
cloth_image.save("cloth_image.png")
|
|
|
|
|
13 |
|
14 |
+
# Create prompt
|
15 |
+
prompt = f"A model wearing the clothing from the second image model_image.png and cloth_image.png"
|
16 |
|
17 |
+
# Generate the merged image
|
18 |
+
output_image = pipeline(
|
19 |
+
prompt,
|
20 |
+
guidance_scale=0.8,
|
21 |
+
num_inference_steps=4,
|
22 |
+
max_sequence_length=256,
|
23 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
24 |
+
).images[0]
|
25 |
+
|
26 |
+
return output_image
|
27 |
|
28 |
# Create the Gradio interface
|
29 |
iface = gr.Interface(
|