Spaces:
Running
on
Zero
Running
on
Zero
adjust target_ratio radio choice in UI if manually changed dimensions
Browse files
app.py
CHANGED
@@ -172,6 +172,13 @@ def preload_presets(target_ratio):
|
|
172 |
elif target_ratio == "Custom":
|
173 |
return 720, 1280, gr.update(open=True)
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
css = """
|
177 |
.gradio-container {
|
@@ -283,6 +290,13 @@ with gr.Blocks(css=css) as demo:
|
|
283 |
queue=False
|
284 |
)
|
285 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
run_button.click(
|
287 |
fn=clear_result,
|
288 |
inputs=None,
|
|
|
172 |
elif target_ratio == "Custom":
|
173 |
return 720, 1280, gr.update(open=True)
|
174 |
|
175 |
+
def select_the_right_preset(user_width, user_height):
|
176 |
+
if user_width == 720 and user_height == 1280:
|
177 |
+
return "9:16"
|
178 |
+
elif user_width == 1280 and user_height == 720:
|
179 |
+
return "16:9"
|
180 |
+
else:
|
181 |
+
return "Custom"
|
182 |
|
183 |
css = """
|
184 |
.gradio-container {
|
|
|
290 |
queue=False
|
291 |
)
|
292 |
|
293 |
+
width_slider.change(
|
294 |
+
fn = select_the_right_preset,
|
295 |
+
inputs = [width_slider, height_slider],
|
296 |
+
outputs = [target_ratio],
|
297 |
+
queue = False
|
298 |
+
)
|
299 |
+
|
300 |
run_button.click(
|
301 |
fn=clear_result,
|
302 |
inputs=None,
|