Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,11 +128,11 @@ def upsample_prompt_logic(prompt, image_list):
|
|
| 128 |
print(f"Upsampling failed: {e}")
|
| 129 |
return prompt
|
| 130 |
|
| 131 |
-
def
|
| 132 |
"""Update width/height sliders based on uploaded image aspect ratio.
|
| 133 |
Keeps one side at 1024 and scales the other proportionally, with both sides as multiples of 8."""
|
| 134 |
if image_list is None or len(image_list) == 0:
|
| 135 |
-
return
|
| 136 |
|
| 137 |
# Get the first image to determine dimensions
|
| 138 |
img = image_list[0][0] # Gallery returns list of tuples (image, caption)
|
|
@@ -191,9 +191,6 @@ def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024,
|
|
| 191 |
|
| 192 |
if randomize_seed:
|
| 193 |
seed = random.randint(0, MAX_SEED)
|
| 194 |
-
|
| 195 |
-
# Auto-update dimensions when images are uploaded
|
| 196 |
-
width, height = update_size_from_image(input_images,width,height)
|
| 197 |
|
| 198 |
# Prepare image list (convert None or empty gallery to None)
|
| 199 |
image_list = None
|
|
@@ -256,6 +253,7 @@ title = "# AI Image Editor"
|
|
| 256 |
description = "AI Image Editor transforms your photos using simple text prompts only. Describe the change you want—from subtle tweaks to major edits—and watch AI instantly deliver professional, high-quality results. Unleash your creativity without complex software! Try unlimited version at [AI image editor](https://www.image2image.ai)."
|
| 257 |
|
| 258 |
with gr.Blocks() as demo:
|
|
|
|
| 259 |
with gr.Column(elem_id="col-container"):
|
| 260 |
gr.Markdown(title)
|
| 261 |
gr.Markdown(description)
|
|
@@ -357,6 +355,13 @@ with gr.Blocks() as demo:
|
|
| 357 |
cache_mode="lazy"
|
| 358 |
)
|
| 359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
gr.on(
|
| 361 |
triggers=[run_button.click, prompt.submit],
|
| 362 |
fn=infer,
|
|
|
|
| 128 |
print(f"Upsampling failed: {e}")
|
| 129 |
return prompt
|
| 130 |
|
| 131 |
+
def update_dimensions_from_image(image_list):
|
| 132 |
"""Update width/height sliders based on uploaded image aspect ratio.
|
| 133 |
Keeps one side at 1024 and scales the other proportionally, with both sides as multiples of 8."""
|
| 134 |
if image_list is None or len(image_list) == 0:
|
| 135 |
+
return 1024, 1024 # Default dimensions
|
| 136 |
|
| 137 |
# Get the first image to determine dimensions
|
| 138 |
img = image_list[0][0] # Gallery returns list of tuples (image, caption)
|
|
|
|
| 191 |
|
| 192 |
if randomize_seed:
|
| 193 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
# Prepare image list (convert None or empty gallery to None)
|
| 196 |
image_list = None
|
|
|
|
| 253 |
description = "AI Image Editor transforms your photos using simple text prompts only. Describe the change you want—from subtle tweaks to major edits—and watch AI instantly deliver professional, high-quality results. Unleash your creativity without complex software! Try unlimited version at [AI image editor](https://www.image2image.ai)."
|
| 254 |
|
| 255 |
with gr.Blocks() as demo:
|
| 256 |
+
|
| 257 |
with gr.Column(elem_id="col-container"):
|
| 258 |
gr.Markdown(title)
|
| 259 |
gr.Markdown(description)
|
|
|
|
| 355 |
cache_mode="lazy"
|
| 356 |
)
|
| 357 |
|
| 358 |
+
# Auto-update dimensions when images are uploaded
|
| 359 |
+
input_images.upload(
|
| 360 |
+
fn=update_dimensions_from_image,
|
| 361 |
+
inputs=[input_images],
|
| 362 |
+
outputs=[width, height]
|
| 363 |
+
)
|
| 364 |
+
|
| 365 |
gr.on(
|
| 366 |
triggers=[run_button.click, prompt.submit],
|
| 367 |
fn=infer,
|