Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -152,6 +152,8 @@ def update_output_resolution(image, scale_choice, custom_scale):
|
|
152 |
width, height = image.size
|
153 |
if scale_choice == "Custom":
|
154 |
scale = custom_scale
|
|
|
|
|
155 |
else:
|
156 |
scale = float(scale_choice.split()[-1].strip("()x"))
|
157 |
return f"Current resolution: {width}x{height}. Output resolution: {int(width*scale)}x{int(height*scale)}"
|
@@ -171,8 +173,16 @@ def update_scale_choices(image):
|
|
171 |
scale = max(w/width, h/height)
|
172 |
if scale > 1:
|
173 |
choices.append(f"{w}x{h} ({scale:.2f}x)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
choices.append("Custom")
|
175 |
-
return gr.update(choices=choices, value=choices[
|
176 |
return gr.update(choices=["Custom"], value="Custom")
|
177 |
|
178 |
# Improved UI design
|
@@ -235,6 +245,8 @@ with gr.Blocks(css=css) as block:
|
|
235 |
def get_scale_value(choice, custom):
|
236 |
if choice == "Custom":
|
237 |
return custom
|
|
|
|
|
238 |
return float(choice.split()[-1].strip("()x"))
|
239 |
|
240 |
inputs = [
|
@@ -243,7 +255,7 @@ with gr.Blocks(css=css) as block:
|
|
243 |
tile_diffusion_stride
|
244 |
]
|
245 |
run_button.click(
|
246 |
-
fn=lambda *args: process(
|
247 |
inputs=inputs + [custom_scale],
|
248 |
outputs=[result_gallery]
|
249 |
)
|
@@ -276,4 +288,4 @@ with gr.Blocks(css=css) as block:
|
|
276 |
outputs=[sr_scale]
|
277 |
)
|
278 |
|
279 |
-
block.launch()
|
|
|
152 |
width, height = image.size
|
153 |
if scale_choice == "Custom":
|
154 |
scale = custom_scale
|
155 |
+
elif "%" in scale_choice:
|
156 |
+
scale = float(scale_choice.split()[-1].strip("()%")) / 100
|
157 |
else:
|
158 |
scale = float(scale_choice.split()[-1].strip("()x"))
|
159 |
return f"Current resolution: {width}x{height}. Output resolution: {int(width*scale)}x{int(height*scale)}"
|
|
|
173 |
scale = max(w/width, h/height)
|
174 |
if scale > 1:
|
175 |
choices.append(f"{w}x{h} ({scale:.2f}x)")
|
176 |
+
|
177 |
+
if not choices: # If no common resolutions fit, use percentage-based options
|
178 |
+
choices = [
|
179 |
+
f"{width*2}x{height*2} (200%)",
|
180 |
+
f"{width*4}x{height*4} (400%)",
|
181 |
+
f"{width*8}x{height*8} (800%)"
|
182 |
+
]
|
183 |
+
|
184 |
choices.append("Custom")
|
185 |
+
return gr.update(choices=choices, value=choices[0])
|
186 |
return gr.update(choices=["Custom"], value="Custom")
|
187 |
|
188 |
# Improved UI design
|
|
|
245 |
def get_scale_value(choice, custom):
|
246 |
if choice == "Custom":
|
247 |
return custom
|
248 |
+
if "%" in choice:
|
249 |
+
return float(choice.split()[-1].strip("()%")) / 100
|
250 |
return float(choice.split()[-1].strip("()x"))
|
251 |
|
252 |
inputs = [
|
|
|
255 |
tile_diffusion_stride
|
256 |
]
|
257 |
run_button.click(
|
258 |
+
fn=lambda *args: process(args[0], args[1], get_scale_value(args[2], args[-1]), *args[3:-1]),
|
259 |
inputs=inputs + [custom_scale],
|
260 |
outputs=[result_gallery]
|
261 |
)
|
|
|
288 |
outputs=[sr_scale]
|
289 |
)
|
290 |
|
291 |
+
block.launch(share=True)
|