Spaces:
Paused
Paused
test gradio
Browse files
app.py
CHANGED
@@ -6,12 +6,15 @@ import os
|
|
6 |
import spaces
|
7 |
from diffusers import StableDiffusion3ControlNetPipeline
|
8 |
from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel
|
|
|
|
|
9 |
# Log in to Hugging Face with your token
|
10 |
token = os.getenv("HF_TOKEN")
|
11 |
login(token=token)
|
12 |
|
13 |
controlnet = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Tile")
|
14 |
pipe = StableDiffusion3ControlNetPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet)
|
|
|
15 |
|
16 |
|
17 |
@spaces.GPU
|
@@ -20,7 +23,7 @@ def generate_image(prompt, reference_image, controlnet_conditioning_scale):
|
|
20 |
# Generate the image with ControlNet conditioning
|
21 |
generated_image = pipe(
|
22 |
prompt=prompt,
|
23 |
-
control_image=reference_image
|
24 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
25 |
).images[0]
|
26 |
return generated_image
|
@@ -30,7 +33,7 @@ interface = gr.Interface(
|
|
30 |
fn=generate_image,
|
31 |
inputs=[
|
32 |
gr.Textbox(label="Prompt"),
|
33 |
-
gr.Image( type= "
|
34 |
gr.Slider(label="Control Net Conditioning Scale", minimum=0, maximum=1.0, step=0.1, value=0.6),
|
35 |
],
|
36 |
outputs="image",
|
|
|
6 |
import spaces
|
7 |
from diffusers import StableDiffusion3ControlNetPipeline
|
8 |
from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel
|
9 |
+
from diffusers.utils import load_image
|
10 |
+
|
11 |
# Log in to Hugging Face with your token
|
12 |
token = os.getenv("HF_TOKEN")
|
13 |
login(token=token)
|
14 |
|
15 |
controlnet = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Tile")
|
16 |
pipe = StableDiffusion3ControlNetPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet)
|
17 |
+
pipe.to("cuda", torch.float16)
|
18 |
|
19 |
|
20 |
@spaces.GPU
|
|
|
23 |
# Generate the image with ControlNet conditioning
|
24 |
generated_image = pipe(
|
25 |
prompt=prompt,
|
26 |
+
control_image=load_image(reference_image),
|
27 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
28 |
).images[0]
|
29 |
return generated_image
|
|
|
33 |
fn=generate_image,
|
34 |
inputs=[
|
35 |
gr.Textbox(label="Prompt"),
|
36 |
+
gr.Image( type= "filepath",label="Reference Image (Style)"),
|
37 |
gr.Slider(label="Control Net Conditioning Scale", minimum=0, maximum=1.0, step=0.1, value=0.6),
|
38 |
],
|
39 |
outputs="image",
|