Spaces:
Running on Zero
Running on Zero
Commit ·
1abb01c
1
Parent(s): a99daf7
Testing CUDA
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: Apollo
|
| 3 |
emoji: 💻
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: yellow
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Apollo
|
| 3 |
emoji: 💻
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: yellow
|
app.py
CHANGED
|
@@ -25,14 +25,17 @@ def save_audio(file_path, audio, samplerate=44100):
|
|
| 25 |
audio = audio.squeeze(0).cpu()
|
| 26 |
torchaudio.save(file_path, audio, samplerate)
|
| 27 |
|
| 28 |
-
#
|
|
|
|
|
|
|
|
|
|
| 29 |
@spaces.GPU
|
| 30 |
@torch.inference_mode()
|
| 31 |
def process_fn(
|
| 32 |
input_audio_path: str
|
| 33 |
) -> str:
|
| 34 |
-
#
|
| 35 |
-
device = torch.device("cpu")
|
| 36 |
|
| 37 |
print(f"Using device: {device}")
|
| 38 |
print("Loading Apollo model...")
|
|
|
|
| 25 |
audio = audio.squeeze(0).cpu()
|
| 26 |
torchaudio.save(file_path, audio, samplerate)
|
| 27 |
|
| 28 |
+
# Load the model outside of the process function so that it only has to happen once
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Defining the process function
|
| 32 |
@spaces.GPU
|
| 33 |
@torch.inference_mode()
|
| 34 |
def process_fn(
|
| 35 |
input_audio_path: str
|
| 36 |
) -> str:
|
| 37 |
+
# Set CUDA device; use CPU as backup
|
| 38 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 39 |
|
| 40 |
print(f"Using device: {device}")
|
| 41 |
print("Loading Apollo model...")
|