Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -172,19 +172,22 @@ def infer(
|
|
| 172 |
num_images_per_prompt=1,
|
| 173 |
).images[0]
|
| 174 |
|
| 175 |
-
# *** FIX: Changed function to return only 2 values to match the button's expectation ***
|
| 176 |
return result, seed
|
| 177 |
|
| 178 |
# --- Wrapper for Examples ---
|
| 179 |
@spaces.GPU
|
| 180 |
-
def infer_example(
|
| 181 |
-
# *** FIX:
|
| 182 |
-
|
|
|
|
|
|
|
| 183 |
# Calculate aspect ratio for the example image
|
| 184 |
width, height = update_dimensions_on_upload(input_pil)
|
| 185 |
-
|
|
|
|
| 186 |
guidance_scale = 1.0
|
| 187 |
steps = 4
|
|
|
|
| 188 |
# Call the main infer function
|
| 189 |
result, seed = infer(input_pil, prompt, lora_adapter, 0, True, guidance_scale, steps, width, height)
|
| 190 |
return result, seed
|
|
@@ -250,7 +253,7 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
|
| 250 |
inputs=[input_image, prompt, lora_adapter],
|
| 251 |
outputs=[output_image, seed],
|
| 252 |
fn=infer_example,
|
| 253 |
-
cache_examples="lazy",
|
| 254 |
label="Examples"
|
| 255 |
)
|
| 256 |
|
|
|
|
| 172 |
num_images_per_prompt=1,
|
| 173 |
).images[0]
|
| 174 |
|
|
|
|
| 175 |
return result, seed
|
| 176 |
|
| 177 |
# --- Wrapper for Examples ---
|
| 178 |
@spaces.GPU
|
| 179 |
+
def infer_example(input_image, prompt, lora_adapter):
|
| 180 |
+
# *** FIX: The input is already a PIL Image object from Gradio, not a path. ***
|
| 181 |
+
# We no longer need Image.open() here.
|
| 182 |
+
input_pil = input_image.convert("RGB")
|
| 183 |
+
|
| 184 |
# Calculate aspect ratio for the example image
|
| 185 |
width, height = update_dimensions_on_upload(input_pil)
|
| 186 |
+
|
| 187 |
+
# Set reasonable default values for example inference to get good results
|
| 188 |
guidance_scale = 1.0
|
| 189 |
steps = 4
|
| 190 |
+
|
| 191 |
# Call the main infer function
|
| 192 |
result, seed = infer(input_pil, prompt, lora_adapter, 0, True, guidance_scale, steps, width, height)
|
| 193 |
return result, seed
|
|
|
|
| 253 |
inputs=[input_image, prompt, lora_adapter],
|
| 254 |
outputs=[output_image, seed],
|
| 255 |
fn=infer_example,
|
| 256 |
+
cache_examples="lazy",
|
| 257 |
label="Examples"
|
| 258 |
)
|
| 259 |
|