Spaces:
Sleeping
Sleeping
Add cold_start time
Browse files
LatentSync/scripts/inference.py
CHANGED
|
@@ -13,6 +13,7 @@
|
|
| 13 |
# limitations under the License.
|
| 14 |
|
| 15 |
import os
|
|
|
|
| 16 |
import argparse
|
| 17 |
from omegaconf import OmegaConf
|
| 18 |
import spaces
|
|
@@ -122,14 +123,16 @@ def get_gpu_duration(**kwargs) -> int:
|
|
| 122 |
The model is monotonic and fits observed points well:
|
| 123 |
3s → ~30s, 8s → ~60s, 30s → ~160s.
|
| 124 |
"""
|
| 125 |
-
import math
|
| 126 |
-
|
| 127 |
audio_length = float(kwargs.get("audio_length", 0.0))
|
| 128 |
-
assert 0.0 < audio_length, "audio_length must be
|
| 129 |
|
| 130 |
estimate = 10.0 + 4.0 * audio_length + 5.0 * math.sqrt(audio_length)
|
| 131 |
duration = int(math.ceil(estimate))
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
# Respect an optional upper cap from environment if set
|
| 134 |
env_cap = os.getenv("SPACES_GPU_TIMEOUT")
|
| 135 |
if env_cap:
|
|
@@ -156,7 +159,8 @@ def run_pipeline(
|
|
| 156 |
weight_dtype=torch.float32,
|
| 157 |
width=256,
|
| 158 |
height=256,
|
| 159 |
-
seed=1247
|
|
|
|
| 160 |
):
|
| 161 |
"""Run the lip-sync pipeline."""
|
| 162 |
audio_encoder = Audio2Feature(
|
|
|
|
| 13 |
# limitations under the License.
|
| 14 |
|
| 15 |
import os
|
| 16 |
+
import math
|
| 17 |
import argparse
|
| 18 |
from omegaconf import OmegaConf
|
| 19 |
import spaces
|
|
|
|
| 123 |
The model is monotonic and fits observed points well:
|
| 124 |
3s → ~30s, 8s → ~60s, 30s → ~160s.
|
| 125 |
"""
|
|
|
|
|
|
|
| 126 |
audio_length = float(kwargs.get("audio_length", 0.0))
|
| 127 |
+
assert 0.0 < audio_length, "audio_length must be positive"
|
| 128 |
|
| 129 |
estimate = 10.0 + 4.0 * audio_length + 5.0 * math.sqrt(audio_length)
|
| 130 |
duration = int(math.ceil(estimate))
|
| 131 |
|
| 132 |
+
cold_start = float(kwargs.get("cold_start", 0.0))
|
| 133 |
+
if 0.0 < cold_start:
|
| 134 |
+
duration += int(math.ceil(cold_start))
|
| 135 |
+
|
| 136 |
# Respect an optional upper cap from environment if set
|
| 137 |
env_cap = os.getenv("SPACES_GPU_TIMEOUT")
|
| 138 |
if env_cap:
|
|
|
|
| 159 |
weight_dtype=torch.float32,
|
| 160 |
width=256,
|
| 161 |
height=256,
|
| 162 |
+
seed=1247,
|
| 163 |
+
cold_start=0.0,
|
| 164 |
):
|
| 165 |
"""Run the lip-sync pipeline."""
|
| 166 |
audio_encoder = Audio2Feature(
|