Spaces:
Runtime error
Runtime error
soujanyaporia
commited on
Commit
•
eb8daef
1
Parent(s):
993ef94
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,16 @@ from audioldm.variational_autoencoder import AutoencoderKL
|
|
10 |
from gradio import Markdown
|
11 |
import spaces
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
class Tango:
|
14 |
-
def __init__(self, name="declare-lab/tango2-full", device=
|
15 |
|
16 |
path = snapshot_download(repo_id=name)
|
17 |
|
@@ -70,9 +78,9 @@ class Tango:
|
|
70 |
# Initialize TANGO
|
71 |
|
72 |
tango = Tango(device="cpu")
|
73 |
-
tango.vae.to(
|
74 |
-
tango.stft.to(
|
75 |
-
tango.model.to(
|
76 |
|
77 |
@spaces.GPU(duration=60)
|
78 |
def gradio_generate(prompt, steps, guidance):
|
@@ -106,8 +114,6 @@ description_text = """
|
|
106 |
<p><a href="https://huggingface.co/spaces/declare-lab/tango2/blob/main/app.py?duplicate=true"> <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> For faster inference without waiting in queue, you may duplicate the space and upgrade to a GPU in the settings. <br/><br/>
|
107 |
Generate audio using Tango2 by providing a text prompt. Tango2 was built from Tango and was trained on <a href="https://huggingface.co/datasets/declare-lab/audio-alpaca">Audio-alpaca</a>
|
108 |
<br/><br/> This is the demo for Tango2 for text to audio generation: <a href="https://arxiv.org/abs/2404.09956">Read our paper.</a>
|
109 |
-
<br>
|
110 |
-
This version is trained on an extended version of Audio-alpaca.
|
111 |
<p/>
|
112 |
"""
|
113 |
# Gradio input and output components
|
|
|
10 |
from gradio import Markdown
|
11 |
import spaces
|
12 |
|
13 |
+
# Automatic device detection
|
14 |
+
if torch.cuda.is_available():
|
15 |
+
device_type = "cuda"
|
16 |
+
device_selection = "cuda:0"
|
17 |
+
else:
|
18 |
+
device_type = "cpu"
|
19 |
+
device_selection = "cpu"
|
20 |
+
|
21 |
class Tango:
|
22 |
+
def __init__(self, name="declare-lab/tango2-full", device=device_selection):
|
23 |
|
24 |
path = snapshot_download(repo_id=name)
|
25 |
|
|
|
78 |
# Initialize TANGO
|
79 |
|
80 |
tango = Tango(device="cpu")
|
81 |
+
tango.vae.to(device_type)
|
82 |
+
tango.stft.to(device_type)
|
83 |
+
tango.model.to(device_type)
|
84 |
|
85 |
@spaces.GPU(duration=60)
|
86 |
def gradio_generate(prompt, steps, guidance):
|
|
|
114 |
<p><a href="https://huggingface.co/spaces/declare-lab/tango2/blob/main/app.py?duplicate=true"> <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> For faster inference without waiting in queue, you may duplicate the space and upgrade to a GPU in the settings. <br/><br/>
|
115 |
Generate audio using Tango2 by providing a text prompt. Tango2 was built from Tango and was trained on <a href="https://huggingface.co/datasets/declare-lab/audio-alpaca">Audio-alpaca</a>
|
116 |
<br/><br/> This is the demo for Tango2 for text to audio generation: <a href="https://arxiv.org/abs/2404.09956">Read our paper.</a>
|
|
|
|
|
117 |
<p/>
|
118 |
"""
|
119 |
# Gradio input and output components
|