Spaces:
Paused
Paused
test gradio
Browse files
app.py
CHANGED
@@ -13,7 +13,6 @@ login(token=token)
|
|
13 |
model_path = 'stabilityai/stable-diffusion-3.5-large'
|
14 |
ip_adapter_path = './ip-adapter.bin'
|
15 |
image_encoder_path = "google/siglip-so400m-patch14-384"
|
16 |
-
ref_img_path = './assets/1.jpg' # Reference image path
|
17 |
|
18 |
# Load SD3.5 pipeline and components
|
19 |
transformer = SD3Transformer2DModel.from_pretrained(
|
@@ -31,43 +30,37 @@ pipe.init_ipadapter(
|
|
31 |
|
32 |
|
33 |
@gr.Interface()
|
34 |
-
def gui_generation(
|
35 |
"""
|
36 |
-
Generate
|
37 |
"""
|
38 |
-
ref_img = Image.open(ref_img_path).convert('RGB') # Load reference image
|
39 |
generator = torch.Generator("cuda").manual_seed(42) # Reproducibility
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
).images[0]
|
54 |
-
images.append(output)
|
55 |
-
return images
|
56 |
|
57 |
|
58 |
# Gradio UI elements
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
number_slider = gr.Slider(1, 5, value=1, step=1, label="Number of Images")
|
63 |
-
gallery = gr.Gallery(label="Generated Images", columns=[3], rows=[1], object_fit="contain", height="auto")
|
64 |
|
65 |
interface = gr.Interface(
|
66 |
gui_generation,
|
67 |
-
inputs=[
|
68 |
-
outputs=
|
69 |
-
title="
|
70 |
-
description="
|
71 |
)
|
72 |
|
73 |
-
interface.launch()
|
|
|
13 |
model_path = 'stabilityai/stable-diffusion-3.5-large'
|
14 |
ip_adapter_path = './ip-adapter.bin'
|
15 |
image_encoder_path = "google/siglip-so400m-patch14-384"
|
|
|
16 |
|
17 |
# Load SD3.5 pipeline and components
|
18 |
transformer = SD3Transformer2DModel.from_pretrained(
|
|
|
30 |
|
31 |
|
32 |
@gr.Interface()
|
33 |
+
def gui_generation(image: Image, style_image: Image):
|
34 |
"""
|
35 |
+
Generate an image based on input and style images.
|
36 |
"""
|
|
|
37 |
generator = torch.Generator("cuda").manual_seed(42) # Reproducibility
|
38 |
|
39 |
+
output = pipe(
|
40 |
+
width=1024,
|
41 |
+
height=1024,
|
42 |
+
prompt="",
|
43 |
+
negative_prompt="",
|
44 |
+
num_inference_steps=24,
|
45 |
+
guidance_scale=5.0,
|
46 |
+
generator=generator,
|
47 |
+
clip_image=style_image,
|
48 |
+
ipadapter_scale=0.5,
|
49 |
+
).images[0]
|
50 |
+
return output
|
|
|
|
|
|
|
51 |
|
52 |
|
53 |
# Gradio UI elements
|
54 |
+
image_input = gr.Image(type="pil", label="Input Image")
|
55 |
+
style_image_input = gr.Image(type="pil", label="Style Image")
|
56 |
+
output_image = gr.Image(label="Generated Image")
|
|
|
|
|
57 |
|
58 |
interface = gr.Interface(
|
59 |
gui_generation,
|
60 |
+
inputs=[image_input, style_image_input],
|
61 |
+
outputs=output_image,
|
62 |
+
title="Image Generation with Style Image",
|
63 |
+
description="Upload an input image and a style image to generate a new image based on the style."
|
64 |
)
|
65 |
|
66 |
+
interface.launch()
|