Spaces:
Running
on
Zero
Running
on
Zero
adapted script for zero gpu
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import argparse
|
|
|
|
| 2 |
import sys
|
| 3 |
from pathlib import Path
|
| 4 |
|
|
@@ -14,7 +15,7 @@ from sfi_utmos.model.ssl_mos import SSLMOSLightningModule
|
|
| 14 |
|
| 15 |
# Global variable for the model
|
| 16 |
model: SSLMOSLightningModule | None = None
|
| 17 |
-
device = "cuda"
|
| 18 |
|
| 19 |
|
| 20 |
def load_model(checkpoint_path: str):
|
|
@@ -28,7 +29,7 @@ def load_model(checkpoint_path: str):
|
|
| 28 |
model.eval()
|
| 29 |
print(f"Model loaded from {checkpoint_path}")
|
| 30 |
|
| 31 |
-
|
| 32 |
def predict_mos(audio_path: str):
|
| 33 |
"""Predicts the MOS score for the given audio file."""
|
| 34 |
if model is None:
|
|
|
|
| 1 |
import argparse
|
| 2 |
+
import spaces
|
| 3 |
import sys
|
| 4 |
from pathlib import Path
|
| 5 |
|
|
|
|
| 15 |
|
| 16 |
# Global variable for the model
|
| 17 |
model: SSLMOSLightningModule | None = None
|
| 18 |
+
device = "cuda"
|
| 19 |
|
| 20 |
|
| 21 |
def load_model(checkpoint_path: str):
|
|
|
|
| 29 |
model.eval()
|
| 30 |
print(f"Model loaded from {checkpoint_path}")
|
| 31 |
|
| 32 |
+
@spaces.GPU
|
| 33 |
def predict_mos(audio_path: str):
|
| 34 |
"""Predicts the MOS score for the given audio file."""
|
| 35 |
if model is None:
|