Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -653,6 +653,18 @@ def calculate_frames(duration: float, frame_rate: float = DEFAULT_FRAME_RATE) ->
|
|
| 653 |
frames = k * 8 + 1
|
| 654 |
return min(frames, MAX_FRAMES)
|
| 655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 656 |
|
| 657 |
def on_image_upload(first_image, last_image, high_res):
|
| 658 |
ref_image = first_image if first_image is not None else last_image
|
|
@@ -670,17 +682,6 @@ def on_highres_toggle(first_image, last_image, high_res):
|
|
| 670 |
return gr.update(value=w), gr.update(value=h)
|
| 671 |
|
| 672 |
|
| 673 |
-
def on_highres_toggle(first_image, last_image, high_res):
|
| 674 |
-
# Always use first_image for resolution calculation
|
| 675 |
-
ref_image = first_image
|
| 676 |
-
if ref_image is None:
|
| 677 |
-
return gr.update(), gr.update()
|
| 678 |
-
aspect = detect_aspect_ratio(ref_image)
|
| 679 |
-
tier = "high" if high_res else "low"
|
| 680 |
-
w, h = RESOLUTIONS[tier][aspect]
|
| 681 |
-
return gr.update(value=w), gr.update(value=h)
|
| 682 |
-
|
| 683 |
-
|
| 684 |
def get_gpu_duration(
|
| 685 |
first_image,
|
| 686 |
last_image,
|
|
@@ -889,7 +890,7 @@ with gr.Blocks(title="LTX-2.3 Two-Stage HQ with LoRA Cache") as demo:
|
|
| 889 |
|
| 890 |
duration = gr.Slider(
|
| 891 |
label="Duration (seconds)",
|
| 892 |
-
minimum=
|
| 893 |
)
|
| 894 |
|
| 895 |
with gr.Row():
|
|
@@ -1023,4 +1024,4 @@ with gr.Blocks(title="LTX-2.3 Two-Stage HQ with LoRA Cache") as demo:
|
|
| 1023 |
|
| 1024 |
|
| 1025 |
if __name__ == "__main__":
|
| 1026 |
-
demo.queue().launch(theme=gr.themes.Citrus(), css=css, mcp_server=
|
|
|
|
| 653 |
frames = k * 8 + 1
|
| 654 |
return min(frames, MAX_FRAMES)
|
| 655 |
|
| 656 |
+
def detect_aspect_ratio(image) -> str:
|
| 657 |
+
if image is None:
|
| 658 |
+
return "16:9"
|
| 659 |
+
if hasattr(image, "size"):
|
| 660 |
+
w, h = image.size
|
| 661 |
+
elif hasattr(image, "shape"):
|
| 662 |
+
h, w = image.shape[:2]
|
| 663 |
+
else:
|
| 664 |
+
return "16:9"
|
| 665 |
+
ratio = w / h
|
| 666 |
+
candidates = {"16:9": 16 / 9, "9:16": 9 / 16, "1:1": 1.0}
|
| 667 |
+
return min(candidates, key=lambda k: abs(ratio - candidates[k]))
|
| 668 |
|
| 669 |
def on_image_upload(first_image, last_image, high_res):
|
| 670 |
ref_image = first_image if first_image is not None else last_image
|
|
|
|
| 682 |
return gr.update(value=w), gr.update(value=h)
|
| 683 |
|
| 684 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 685 |
def get_gpu_duration(
|
| 686 |
first_image,
|
| 687 |
last_image,
|
|
|
|
| 890 |
|
| 891 |
duration = gr.Slider(
|
| 892 |
label="Duration (seconds)",
|
| 893 |
+
minimum=1.0, maximum=30.0, value=10.0, step=0.1,
|
| 894 |
)
|
| 895 |
|
| 896 |
with gr.Row():
|
|
|
|
| 1024 |
|
| 1025 |
|
| 1026 |
if __name__ == "__main__":
|
| 1027 |
+
demo.queue().launch(theme=gr.themes.Citrus(), css=css, mcp_server=False)
|