Spaces:
Paused
Paused
test gradio
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from diffusers import StableDiffusion3ControlNetPipeline, SD3ControlNetModel, Un
|
|
4 |
from huggingface_hub import login
|
5 |
import os
|
6 |
import spaces
|
|
|
7 |
# Log in to Hugging Face with your token
|
8 |
token = os.getenv("HF_TOKEN")
|
9 |
login(token=token)
|
@@ -21,9 +22,9 @@ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
21 |
pipe = pipe.to("cuda")
|
22 |
|
23 |
@spaces.GPU
|
24 |
-
def generate_image(prompt, reference_image,controlnet_conditioning_scale):
|
25 |
# Prepare the reference image for ControlNet
|
26 |
-
reference_image = reference_image.convert("RGB").resize((1024, 1024))
|
27 |
|
28 |
# Generate the image with ControlNet conditioning
|
29 |
generated_image = pipe(
|
@@ -31,7 +32,7 @@ def generate_image(prompt, reference_image,controlnet_conditioning_scale):
|
|
31 |
control_image=reference_image,
|
32 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
33 |
guidance_scale=7.5,
|
34 |
-
num_inference_steps=50
|
35 |
).images[0]
|
36 |
return generated_image
|
37 |
|
@@ -41,7 +42,7 @@ interface = gr.Interface(
|
|
41 |
inputs=[
|
42 |
gr.Textbox(label="Prompt"),
|
43 |
gr.Image(type="pil", label="Reference Image (Style)"),
|
44 |
-
gr.Slider(label="Control Net Conditioning Scale",minimum=0,maximum=1),
|
45 |
],
|
46 |
outputs="image",
|
47 |
title="Image Generation with Stable Diffusion 3.5 and ControlNet",
|
|
|
4 |
from huggingface_hub import login
|
5 |
import os
|
6 |
import spaces
|
7 |
+
|
8 |
# Log in to Hugging Face with your token
|
9 |
token = os.getenv("HF_TOKEN")
|
10 |
login(token=token)
|
|
|
22 |
pipe = pipe.to("cuda")
|
23 |
|
24 |
@spaces.GPU
|
25 |
+
def generate_image(prompt, reference_image, controlnet_conditioning_scale):
|
26 |
# Prepare the reference image for ControlNet
|
27 |
+
reference_image = reference_image.convert("RGB").resize((1024, 1024), Image.LANCZOS)
|
28 |
|
29 |
# Generate the image with ControlNet conditioning
|
30 |
generated_image = pipe(
|
|
|
32 |
control_image=reference_image,
|
33 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
34 |
guidance_scale=7.5,
|
35 |
+
num_inference_steps=75 # Increased from 50 to refine quality
|
36 |
).images[0]
|
37 |
return generated_image
|
38 |
|
|
|
42 |
inputs=[
|
43 |
gr.Textbox(label="Prompt"),
|
44 |
gr.Image(type="pil", label="Reference Image (Style)"),
|
45 |
+
gr.Slider(label="Control Net Conditioning Scale", minimum=0.5, maximum=2.0, step=0.1, value=1.0),
|
46 |
],
|
47 |
outputs="image",
|
48 |
title="Image Generation with Stable Diffusion 3.5 and ControlNet",
|