Spaces:
Running
on
Zero
Running
on
Zero
Update inference_gradio.py
Browse files- inference_gradio.py +4 -12
inference_gradio.py
CHANGED
|
@@ -82,15 +82,8 @@ class UVR5:
|
|
| 82 |
# main process. The heavy UVR5 loading happens lazily inside
|
| 83 |
# @spaces.GPU functions; this guard is kept only for the CPU path to
|
| 84 |
# avoid any accidental CUDA init.
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
torch.cuda.is_available = lambda: False
|
| 88 |
-
try:
|
| 89 |
-
uvr5_model.load_model(model_path, 1)
|
| 90 |
-
finally:
|
| 91 |
-
torch.cuda.is_available = orig_is_available
|
| 92 |
-
else:
|
| 93 |
-
uvr5_model.load_model(model_path, 1)
|
| 94 |
|
| 95 |
self.model = uvr5_model
|
| 96 |
self.device = device
|
|
@@ -99,10 +92,9 @@ class UVR5:
|
|
| 99 |
def denoise(self, audio_info):
|
| 100 |
# Prefer GPU if available; on Spaces this runs inside @spaces.GPU so
|
| 101 |
# CUDA can be safely initialized here.
|
| 102 |
-
|
| 103 |
-
model = self.load_model(device=device)
|
| 104 |
input_audio = load_wav(audio_info, sr=44100, channel=2)
|
| 105 |
-
output_audio = model.demix_base({0:input_audio.squeeze()}, is_match_mix=False, device=
|
| 106 |
# transform = torchaudio.transforms.Resample(44100, 16000)
|
| 107 |
# output_audio = transform(output_audio)
|
| 108 |
return output_audio.squeeze().T.cpu().numpy(), 44100
|
|
|
|
| 82 |
# main process. The heavy UVR5 loading happens lazily inside
|
| 83 |
# @spaces.GPU functions; this guard is kept only for the CPU path to
|
| 84 |
# avoid any accidental CUDA init.
|
| 85 |
+
|
| 86 |
+
uvr5_model.load_model(model_path, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
self.model = uvr5_model
|
| 89 |
self.device = device
|
|
|
|
| 92 |
def denoise(self, audio_info):
|
| 93 |
# Prefer GPU if available; on Spaces this runs inside @spaces.GPU so
|
| 94 |
# CUDA can be safely initialized here.
|
| 95 |
+
model = self.load_model(device="cpu")
|
|
|
|
| 96 |
input_audio = load_wav(audio_info, sr=44100, channel=2)
|
| 97 |
+
output_audio = model.demix_base({0:input_audio.squeeze()}, is_match_mix=False, device="cpu")
|
| 98 |
# transform = torchaudio.transforms.Resample(44100, 16000)
|
| 99 |
# output_audio = transform(output_audio)
|
| 100 |
return output_audio.squeeze().T.cpu().numpy(), 44100
|