Spaces:
Running
on
A10G
Running
on
A10G
trying fix
Browse files- app.py +1 -1
- app_batched.py +120 -61
app.py
CHANGED
@@ -182,7 +182,7 @@ if __name__ == "__main__":
|
|
182 |
parser.add_argument(
|
183 |
'--listen',
|
184 |
type=str,
|
185 |
-
default='
|
186 |
help='IP to listen on for connections to Gradio',
|
187 |
)
|
188 |
parser.add_argument(
|
|
|
182 |
parser.add_argument(
|
183 |
'--listen',
|
184 |
type=str,
|
185 |
+
default='0.0.0.0',
|
186 |
help='IP to listen on for connections to Gradio',
|
187 |
)
|
188 |
parser.add_argument(
|
app_batched.py
CHANGED
@@ -96,68 +96,127 @@ def predict(texts, melodies):
|
|
96 |
return res
|
97 |
|
98 |
|
99 |
-
|
100 |
-
gr.
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
with gr.
|
114 |
-
with gr.
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
[
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
],
|
141 |
-
[
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
)
|
149 |
-
gr.Markdown("""
|
150 |
-
### More details
|
151 |
-
|
152 |
-
The model will generate 12 seconds of audio based on the description you provided.
|
153 |
-
You can optionaly provide a reference audio from which a broad melody will be extracted.
|
154 |
-
The model will then try to follow both the description and melody provided.
|
155 |
-
All samples are generated with the `melody` model.
|
156 |
-
|
157 |
-
You can also use your own GPU or a Google Colab by following the instructions on our repo.
|
158 |
|
159 |
-
|
160 |
-
for more details.
|
161 |
-
""")
|
162 |
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
return res
|
97 |
|
98 |
|
99 |
+
def ui(**kwargs):
|
100 |
+
with gr.Blocks() as demo:
|
101 |
+
gr.Markdown(
|
102 |
+
"""
|
103 |
+
# MusicGen
|
104 |
+
|
105 |
+
This is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generation
|
106 |
+
presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).
|
107 |
+
<br/>
|
108 |
+
<a href="https://huggingface.co/spaces/musicgen/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank">
|
109 |
+
<img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
110 |
+
for longer sequences, more control and no queue.</p>
|
111 |
+
"""
|
112 |
+
)
|
113 |
+
with gr.Row():
|
114 |
+
with gr.Column():
|
115 |
+
with gr.Row():
|
116 |
+
text = gr.Text(label="Describe your music", lines=2, interactive=True)
|
117 |
+
melody = gr.Audio(source="upload", type="numpy", label="Condition on a melody (optional)", interactive=True)
|
118 |
+
with gr.Row():
|
119 |
+
submit = gr.Button("Generate")
|
120 |
+
with gr.Column():
|
121 |
+
output = gr.Video(label="Generated Music")
|
122 |
+
submit.click(predict, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=8)
|
123 |
+
gr.Examples(
|
124 |
+
fn=predict,
|
125 |
+
examples=[
|
126 |
+
[
|
127 |
+
"An 80s driving pop song with heavy drums and synth pads in the background",
|
128 |
+
"./assets/bach.mp3",
|
129 |
+
],
|
130 |
+
[
|
131 |
+
"A cheerful country song with acoustic guitars",
|
132 |
+
"./assets/bolero_ravel.mp3",
|
133 |
+
],
|
134 |
+
[
|
135 |
+
"90s rock song with electric guitar and heavy drums",
|
136 |
+
None,
|
137 |
+
],
|
138 |
+
[
|
139 |
+
"a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
|
140 |
+
"./assets/bach.mp3",
|
141 |
+
],
|
142 |
+
[
|
143 |
+
"lofi slow bpm electro chill with organic samples",
|
144 |
+
None,
|
145 |
+
],
|
146 |
],
|
147 |
+
inputs=[text, melody],
|
148 |
+
outputs=[output]
|
149 |
+
)
|
150 |
+
gr.Markdown("""
|
151 |
+
### More details
|
152 |
+
|
153 |
+
The model will generate 12 seconds of audio based on the description you provided.
|
154 |
+
You can optionaly provide a reference audio from which a broad melody will be extracted.
|
155 |
+
The model will then try to follow both the description and melody provided.
|
156 |
+
All samples are generated with the `melody` model.
|
157 |
+
|
158 |
+
You can also use your own GPU or a Google Colab by following the instructions on our repo.
|
159 |
+
|
160 |
+
See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
|
161 |
+
for more details.
|
162 |
+
""")
|
163 |
+
|
164 |
+
# Show the interface
|
165 |
+
launch_kwargs = {}
|
166 |
+
username = kwargs.get('username')
|
167 |
+
password = kwargs.get('password')
|
168 |
+
server_port = kwargs.get('server_port', 0)
|
169 |
+
inbrowser = kwargs.get('inbrowser', False)
|
170 |
+
share = kwargs.get('share', False)
|
171 |
+
server_name = kwargs.get('listen')
|
172 |
+
|
173 |
+
launch_kwargs['server_name'] = server_name
|
174 |
+
|
175 |
+
if username and password:
|
176 |
+
launch_kwargs['auth'] = (username, password)
|
177 |
+
if server_port > 0:
|
178 |
+
launch_kwargs['server_port'] = server_port
|
179 |
+
if inbrowser:
|
180 |
+
launch_kwargs['inbrowser'] = inbrowser
|
181 |
+
if share:
|
182 |
+
launch_kwargs['share'] = share
|
183 |
+
demo.queue(max_size=8 * 4).launch(**launch_kwargs)
|
184 |
+
|
185 |
+
|
186 |
+
if __name__ == "__main__":
|
187 |
+
parser = argparse.ArgumentParser()
|
188 |
+
parser.add_argument(
|
189 |
+
'--listen',
|
190 |
+
type=str,
|
191 |
+
default='0.0.0.0',
|
192 |
+
help='IP to listen on for connections to Gradio',
|
193 |
+
)
|
194 |
+
parser.add_argument(
|
195 |
+
'--username', type=str, default='', help='Username for authentication'
|
196 |
+
)
|
197 |
+
parser.add_argument(
|
198 |
+
'--password', type=str, default='', help='Password for authentication'
|
199 |
+
)
|
200 |
+
parser.add_argument(
|
201 |
+
'--server_port',
|
202 |
+
type=int,
|
203 |
+
default=0,
|
204 |
+
help='Port to run the server listener on',
|
205 |
+
)
|
206 |
+
parser.add_argument(
|
207 |
+
'--inbrowser', action='store_true', help='Open in browser'
|
208 |
+
)
|
209 |
+
parser.add_argument(
|
210 |
+
'--share', action='store_true', help='Share the gradio UI'
|
211 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
+
args = parser.parse_args()
|
|
|
|
|
214 |
|
215 |
+
ui(
|
216 |
+
username=args.username,
|
217 |
+
password=args.password,
|
218 |
+
inbrowser=args.inbrowser,
|
219 |
+
server_port=args.server_port,
|
220 |
+
share=args.share,
|
221 |
+
listen=args.listen
|
222 |
+
)
|