Spaces:
Running on Zero
Running on Zero
Extend ZeroGPU duration for dataset runs
Browse files
app.py
CHANGED
|
@@ -65,6 +65,21 @@ def log_progress(message: str, level: int = 1, enabled: bool = True) -> None:
|
|
| 65 |
# Load environment variables
|
| 66 |
load_dotenv()
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
def get_hf_token() -> Optional[str]:
|
| 70 |
return (
|
|
@@ -722,7 +737,7 @@ def default_output_repo(source_id: str, username: str) -> str:
|
|
| 722 |
return f"{username}/{name}"
|
| 723 |
|
| 724 |
|
| 725 |
-
@
|
| 726 |
def process_dataset_and_push(
|
| 727 |
dataset_id: str,
|
| 728 |
config: str,
|
|
@@ -1206,7 +1221,7 @@ def assemble_cached_dataset_and_push(
|
|
| 1206 |
)
|
| 1207 |
|
| 1208 |
|
| 1209 |
-
@
|
| 1210 |
def gradio_single_file(
|
| 1211 |
audio_file,
|
| 1212 |
vad_threshold,
|
|
|
|
| 65 |
# Load environment variables
|
| 66 |
load_dotenv()
|
| 67 |
|
| 68 |
+
_GPU_DURATION = os.getenv("CHIZZLER_GPU_DURATION")
|
| 69 |
+
if _GPU_DURATION is not None:
|
| 70 |
+
DEFAULT_GPU_DURATION = int(_GPU_DURATION)
|
| 71 |
+
else:
|
| 72 |
+
DEFAULT_GPU_DURATION = 3600 if os.getenv("SPACE_ID") else 0
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def gpu_decorator(duration: int):
|
| 76 |
+
if duration and duration > 0:
|
| 77 |
+
try:
|
| 78 |
+
return spaces.GPU(duration=duration)
|
| 79 |
+
except TypeError:
|
| 80 |
+
return spaces.GPU
|
| 81 |
+
return spaces.GPU
|
| 82 |
+
|
| 83 |
|
| 84 |
def get_hf_token() -> Optional[str]:
|
| 85 |
return (
|
|
|
|
| 737 |
return f"{username}/{name}"
|
| 738 |
|
| 739 |
|
| 740 |
+
@gpu_decorator(DEFAULT_GPU_DURATION)
|
| 741 |
def process_dataset_and_push(
|
| 742 |
dataset_id: str,
|
| 743 |
config: str,
|
|
|
|
| 1221 |
)
|
| 1222 |
|
| 1223 |
|
| 1224 |
+
@gpu_decorator(DEFAULT_GPU_DURATION)
|
| 1225 |
def gradio_single_file(
|
| 1226 |
audio_file,
|
| 1227 |
vad_threshold,
|