fffiloni commited on
Commit
2356bb5
·
verified ·
1 Parent(s): 4df090e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -2
app.py CHANGED
@@ -515,7 +515,33 @@ def find_diagnostic(output_dir: Path, output_path: Path, kind: str) -> Optional[
515
  STARTUP_OK, STARTUP_LOG = startup_preflight()
516
 
517
 
518
- @spaces.GPU(duration=3600, size="xlarge")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  def run_inference(
520
  preset_name: str,
521
  source_mode: str,
@@ -985,4 +1011,4 @@ if __name__ == "__main__":
985
  server_name=args.server_name,
986
  server_port=args.server_port,
987
  show_error=True,
988
- )
 
515
  STARTUP_OK, STARTUP_LOG = startup_preflight()
516
 
517
 
518
+ def estimate_gpu_duration(
519
+ preset_name: str,
520
+ source_mode: str,
521
+ sample_name: Optional[str],
522
+ dataset_zip: Optional[Any],
523
+ env_mode: str,
524
+ env_name: Optional[str],
525
+ env_zip: Optional[Any],
526
+ steps: int,
527
+ cfg_scale: float,
528
+ quality: int,
529
+ wo_ref_weight: float,
530
+ drop_mr: bool,
531
+ use_multi_ref: bool,
532
+ ) -> int:
533
+ preset = PRESETS.get(preset_name, PRESETS["Basic 25-frame relighting"])
534
+ frames = int(preset["frames"])
535
+ steps = int(steps)
536
+
537
+ if frames == 1:
538
+ return min(150, max(45, 25 + steps * 2))
539
+ if frames <= 25:
540
+ return min(900, max(180, 90 + steps * 10))
541
+ return min(1500, max(300, 180 + steps * 18))
542
+
543
+
544
+ @spaces.GPU(duration=estimate_gpu_duration, size="large")
545
  def run_inference(
546
  preset_name: str,
547
  source_mode: str,
 
1011
  server_name=args.server_name,
1012
  server_port=args.server_port,
1013
  show_error=True,
1014
+ )