DawnC commited on
Commit
a60db3a
·
verified ·
1 Parent(s): e1c1826

Upload FlowFacade.py

Browse files
Files changed (1) hide show
  1. FlowFacade.py +6 -6
FlowFacade.py CHANGED
@@ -27,9 +27,9 @@ class FlowFacade:
27
  print("✓ DeltaFlow initialized")
28
 
29
  def _calculate_gpu_duration(self, image: Image.Image, duration_seconds: float,
30
- num_inference_steps: int, enable_prompt_expansion: bool) -> int:
31
  BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
32
- BASE_STEP_DURATION = 15
33
 
34
  resized_image = self.video_engine.resize_image(image)
35
  width, height = resized_image.width, resized_image.height
@@ -37,14 +37,14 @@ class FlowFacade:
37
 
38
  factor = frames * width * height / BASE_FRAMES_HEIGHT_WIDTH
39
  step_duration = BASE_STEP_DURATION * factor ** 1.5
40
- total_duration = 10 + int(num_inference_steps) * step_duration
41
 
42
  if enable_prompt_expansion:
43
- total_duration += 30
44
 
45
- return int(total_duration)
46
 
47
- @spaces.GPU(duration=120)
48
  def generate_video_from_image(self, image: Image.Image, user_instruction: str,
49
  duration_seconds: float = 3.0, num_inference_steps: int = 4,
50
  guidance_scale: float = 1.0, guidance_scale_2: float = 1.0,
 
27
  print("✓ DeltaFlow initialized")
28
 
29
  def _calculate_gpu_duration(self, image: Image.Image, duration_seconds: float,
30
+ num_inference_steps: int, enable_prompt_expansion: bool, **kwargs) -> int:
31
  BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
32
+ BASE_STEP_DURATION = 20
33
 
34
  resized_image = self.video_engine.resize_image(image)
35
  width, height = resized_image.width, resized_image.height
 
37
 
38
  factor = frames * width * height / BASE_FRAMES_HEIGHT_WIDTH
39
  step_duration = BASE_STEP_DURATION * factor ** 1.5
40
+ total_duration = 30 + int(num_inference_steps) * step_duration
41
 
42
  if enable_prompt_expansion:
43
+ total_duration += 40
44
 
45
+ return max(int(total_duration), 180)
46
 
47
+ @spaces.GPU(duration=_calculate_gpu_duration)
48
  def generate_video_from_image(self, image: Image.Image, user_instruction: str,
49
  duration_seconds: float = 3.0, num_inference_steps: int = 4,
50
  guidance_scale: float = 1.0, guidance_scale_2: float = 1.0,