dagloop5 commited on
Commit
90a1e9a
·
verified ·
1 Parent(s): 457b2da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -25
app.py CHANGED
@@ -654,33 +654,16 @@ def calculate_frames(duration: float, frame_rate: float = DEFAULT_FRAME_RATE) ->
654
  return min(frames, MAX_FRAMES)
655
 
656
 
657
- def validate_resolution(height: int, width: int) -> tuple[int, int]:
658
- height = round(height / STEP) * STEP
659
- width = round(width / STEP) * STEP
660
- height = max(MIN_DIM, min(height, MAX_DIM))
661
- width = max(MIN_DIM, min(width, MAX_DIM))
662
- return height, width
663
-
664
-
665
- def detect_aspect_ratio(image) -> str:
666
- if image is None:
667
- return "16:9"
668
- if hasattr(image, "size"):
669
- w, h = image.size
670
- elif hasattr(image, "shape"):
671
- h, w = image.shape[:2]
672
- else:
673
- return "16:9"
674
- ratio = w / h
675
- candidates = {"16:9": 16/9, "9:16": 9/16, "1:1": 1.0}
676
- return min(candidates, key=lambda k: abs(ratio - candidates[k]))
677
 
678
 
679
- def on_image_upload(first_image, last_image, high_res):
680
- # Always use first_image for resolution calculation
681
- ref_image = first_image
682
- if ref_image is None:
683
- return gr.update(), gr.update()
684
  aspect = detect_aspect_ratio(ref_image)
685
  tier = "high" if high_res else "low"
686
  w, h = RESOLUTIONS[tier][aspect]
 
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
659
+ aspect = detect_aspect_ratio(ref_image)
660
+ tier = "high" if high_res else "low"
661
+ w, h = RESOLUTIONS[tier][aspect]
662
+ return gr.update(value=w), gr.update(value=h)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
 
664
 
665
+ def on_highres_toggle(first_image, last_image, high_res):
666
+ ref_image = first_image if first_image is not None else last_image
 
 
 
667
  aspect = detect_aspect_ratio(ref_image)
668
  tier = "high" if high_res else "low"
669
  w, h = RESOLUTIONS[tier][aspect]