Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ CONTROL_MODES = {
|
|
33 |
def preprocess_image(image, target_width, target_height):
|
34 |
image = image.resize((target_width, target_height), Image.LANCZOS)
|
35 |
return image
|
36 |
-
|
37 |
@spaces.GPU(duration=120)
|
38 |
def generate_image(prompt, control_image, control_mode, controlnet_conditioning_scale, num_steps, guidance, width, height, seed, random_seed):
|
39 |
if random_seed:
|
@@ -49,12 +49,15 @@ def generate_image(prompt, control_image, control_mode, controlnet_conditioning_
|
|
49 |
# Preprocess control image
|
50 |
control_image = preprocess_image(control_image, width, height)
|
51 |
|
|
|
|
|
|
|
52 |
# Generate the image with the selected control mode and other parameters
|
53 |
with torch.no_grad():
|
54 |
image = pipe(
|
55 |
prompt,
|
56 |
control_image=control_image,
|
57 |
-
control_mode=
|
58 |
width=width,
|
59 |
height=height,
|
60 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
@@ -70,7 +73,7 @@ interface = gr.Interface(
|
|
70 |
inputs=[
|
71 |
gr.Textbox(label="Prompt"),
|
72 |
gr.Image(type="pil", label="Control Image"),
|
73 |
-
gr.Dropdown(choices=[
|
74 |
gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="ControlNet Conditioning Scale"),
|
75 |
gr.Slider(step=1, minimum=1, maximum=64, value=24, label="Num Steps"),
|
76 |
gr.Slider(minimum=0.1, maximum=10, value=3.5, label="Guidance"),
|
|
|
33 |
def preprocess_image(image, target_width, target_height):
|
34 |
image = image.resize((target_width, target_height), Image.LANCZOS)
|
35 |
return image
|
36 |
+
|
37 |
@spaces.GPU(duration=120)
|
38 |
def generate_image(prompt, control_image, control_mode, controlnet_conditioning_scale, num_steps, guidance, width, height, seed, random_seed):
|
39 |
if random_seed:
|
|
|
49 |
# Preprocess control image
|
50 |
control_image = preprocess_image(control_image, width, height)
|
51 |
|
52 |
+
# Ensure control_mode is an integer
|
53 |
+
control_mode_index = int(control_mode)
|
54 |
+
|
55 |
# Generate the image with the selected control mode and other parameters
|
56 |
with torch.no_grad():
|
57 |
image = pipe(
|
58 |
prompt,
|
59 |
control_image=control_image,
|
60 |
+
control_mode=control_mode_index, # Pass control mode as an integer
|
61 |
width=width,
|
62 |
height=height,
|
63 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
|
|
73 |
inputs=[
|
74 |
gr.Textbox(label="Prompt"),
|
75 |
gr.Image(type="pil", label="Control Image"),
|
76 |
+
gr.Dropdown(choices=[(i, name) for i, name in CONTROL_MODES.items()], label="Control Mode", value=0), # Correct value and format for dropdown
|
77 |
gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="ControlNet Conditioning Scale"),
|
78 |
gr.Slider(step=1, minimum=1, maximum=64, value=24, label="Num Steps"),
|
79 |
gr.Slider(minimum=0.1, maximum=10, value=3.5, label="Guidance"),
|