Wataru commited on
Commit
70722dd
·
1 Parent(s): 9ef6927

adapted script for zero gpu

Browse files
Files changed (1) hide show
  1. app.py +3 -2
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" if torch.cuda.is_available() else "cpu"
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: