Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
import re
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
import tempfile
|
| 6 |
from einops import rearrange
|
| 7 |
-
#from vocos import Vocos
|
| 8 |
from pydub import AudioSegment, silence
|
| 9 |
from model import CFM, UNetT, DiT, MMDiT
|
| 10 |
from cached_path import cached_path
|
|
@@ -25,19 +23,24 @@ from transformers import pipeline
|
|
| 25 |
import click
|
| 26 |
import soundfile as sf
|
| 27 |
|
|
|
|
| 28 |
try:
|
| 29 |
import spaces
|
| 30 |
USING_SPACES = True
|
| 31 |
except ImportError:
|
| 32 |
USING_SPACES = False
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def gpu_decorator(func):
|
| 35 |
if USING_SPACES:
|
| 36 |
return spaces.GPU(func)
|
| 37 |
else:
|
| 38 |
return func
|
| 39 |
-
|
| 40 |
-
import torchaudio
|
| 41 |
# Determine the device
|
| 42 |
device = (
|
| 43 |
"cuda"
|
|
@@ -55,7 +58,6 @@ else:
|
|
| 55 |
|
| 56 |
# Create the torch.device object
|
| 57 |
device = torch.device(device)
|
| 58 |
-
|
| 59 |
print(f"Using device: {device}, dtype: {dtype}")
|
| 60 |
|
| 61 |
pipe = pipeline(
|
|
|
|
| 1 |
import re
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import numpy as np
|
| 4 |
import tempfile
|
| 5 |
from einops import rearrange
|
|
|
|
| 6 |
from pydub import AudioSegment, silence
|
| 7 |
from model import CFM, UNetT, DiT, MMDiT
|
| 8 |
from cached_path import cached_path
|
|
|
|
| 23 |
import click
|
| 24 |
import soundfile as sf
|
| 25 |
|
| 26 |
+
# Import 'spaces' early to avoid CUDA initialization conflicts
|
| 27 |
try:
|
| 28 |
import spaces
|
| 29 |
USING_SPACES = True
|
| 30 |
except ImportError:
|
| 31 |
USING_SPACES = False
|
| 32 |
|
| 33 |
+
# Import PyTorch and related libraries after 'spaces'
|
| 34 |
+
import torch
|
| 35 |
+
import torchaudio
|
| 36 |
+
|
| 37 |
+
# GPU decorator handling for 'spaces'
|
| 38 |
def gpu_decorator(func):
|
| 39 |
if USING_SPACES:
|
| 40 |
return spaces.GPU(func)
|
| 41 |
else:
|
| 42 |
return func
|
| 43 |
+
|
|
|
|
| 44 |
# Determine the device
|
| 45 |
device = (
|
| 46 |
"cuda"
|
|
|
|
| 58 |
|
| 59 |
# Create the torch.device object
|
| 60 |
device = torch.device(device)
|
|
|
|
| 61 |
print(f"Using device: {device}, dtype: {dtype}")
|
| 62 |
|
| 63 |
pipe = pipeline(
|