Spaces:
Running on Zero
Running on Zero
gpu_duration
Browse files- backend.py +7 -2
backend.py
CHANGED
|
@@ -100,6 +100,7 @@ def _duration_for(
|
|
| 100 |
mode: str,
|
| 101 |
preset: str,
|
| 102 |
multiplier: float = 1.0,
|
|
|
|
| 103 |
progress: Any = None,
|
| 104 |
) -> int:
|
| 105 |
"""ZeroGPU duration estimator. Same signature as _execute_workflow.
|
|
@@ -115,6 +116,9 @@ def _duration_for(
|
|
| 115 |
needed for style + lipsync detailer paths). If the server rejects values
|
| 116 |
in this range, the user will see a clear error and can retry.
|
| 117 |
"""
|
|
|
|
|
|
|
|
|
|
| 118 |
base = _BASE_DURATION_S.get(mode, 180)
|
| 119 |
mult = _PRESET_MULT.get(preset.lower(), 1.5)
|
| 120 |
frames = _frames_from_workflow(workflow)
|
|
@@ -138,6 +142,7 @@ def _execute_workflow(
|
|
| 138 |
mode: str,
|
| 139 |
preset: str,
|
| 140 |
multiplier: float = 1.0,
|
|
|
|
| 141 |
progress: Any = None,
|
| 142 |
) -> str:
|
| 143 |
"""Run the workflow on GPU and return the path of the first video output.
|
|
@@ -385,7 +390,7 @@ class ComfyUILibraryBackend:
|
|
| 385 |
*,
|
| 386 |
preset: str = "balanced",
|
| 387 |
duration_multiplier: float = 1.0,
|
| 388 |
-
gpu_duration: int =
|
| 389 |
progress: Any = None,
|
| 390 |
) -> AsyncIterator[Any]:
|
| 391 |
"""Run a workflow end-to-end. Yields Download/Progress/Output/Error events.
|
|
@@ -467,7 +472,7 @@ class ComfyUILibraryBackend:
|
|
| 467 |
# light calls get fast queue priority while heavy ones reserve
|
| 468 |
# real headroom. Off-Spaces it's a plain call.
|
| 469 |
video_path = _execute_workflow(
|
| 470 |
-
self._executor, workflow, output_ids, mode, preset, duration_multiplier, progress,
|
| 471 |
)
|
| 472 |
# Fallback: if history_result didn't surface a path (rare on
|
| 473 |
# Spaces — happens when ZeroGPU's subprocess boundary drops
|
|
|
|
| 100 |
mode: str,
|
| 101 |
preset: str,
|
| 102 |
multiplier: float = 1.0,
|
| 103 |
+
gpu_duration: int = -1,
|
| 104 |
progress: Any = None,
|
| 105 |
) -> int:
|
| 106 |
"""ZeroGPU duration estimator. Same signature as _execute_workflow.
|
|
|
|
| 116 |
needed for style + lipsync detailer paths). If the server rejects values
|
| 117 |
in this range, the user will see a clear error and can retry.
|
| 118 |
"""
|
| 119 |
+
if gpu_duration != -1:
|
| 120 |
+
return gpu_duration
|
| 121 |
+
|
| 122 |
base = _BASE_DURATION_S.get(mode, 180)
|
| 123 |
mult = _PRESET_MULT.get(preset.lower(), 1.5)
|
| 124 |
frames = _frames_from_workflow(workflow)
|
|
|
|
| 142 |
mode: str,
|
| 143 |
preset: str,
|
| 144 |
multiplier: float = 1.0,
|
| 145 |
+
gpu_duration: int = -1,
|
| 146 |
progress: Any = None,
|
| 147 |
) -> str:
|
| 148 |
"""Run the workflow on GPU and return the path of the first video output.
|
|
|
|
| 390 |
*,
|
| 391 |
preset: str = "balanced",
|
| 392 |
duration_multiplier: float = 1.0,
|
| 393 |
+
gpu_duration: int = -1,
|
| 394 |
progress: Any = None,
|
| 395 |
) -> AsyncIterator[Any]:
|
| 396 |
"""Run a workflow end-to-end. Yields Download/Progress/Output/Error events.
|
|
|
|
| 472 |
# light calls get fast queue priority while heavy ones reserve
|
| 473 |
# real headroom. Off-Spaces it's a plain call.
|
| 474 |
video_path = _execute_workflow(
|
| 475 |
+
self._executor, workflow, output_ids, mode, preset, duration_multiplier, gpu_duration, progress,
|
| 476 |
)
|
| 477 |
# Fallback: if history_result didn't surface a path (rare on
|
| 478 |
# Spaces — happens when ZeroGPU's subprocess boundary drops
|