adefossez commited on
Commit
8682185
1 Parent(s): a31f19b

trying to debug

Browse files
Files changed (1) hide show
  1. app_batched.py +61 -120
app_batched.py CHANGED
@@ -96,127 +96,68 @@ def predict(texts, melodies):
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='127.0.0.1',
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
- )
 
96
  return res
97
 
98
 
99
+ with gr.Blocks() as demo:
100
+ gr.Markdown(
101
+ """
102
+ # MusicGen
103
+
104
+ This is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generation
105
+ presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).
106
+ <br/>
107
+ <a href="https://huggingface.co/spaces/musicgen/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank">
108
+ <img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
109
+ for longer sequences, more control and no queue.</p>
110
+ """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  )
112
+ with gr.Row():
113
+ with gr.Column():
114
+ with gr.Row():
115
+ text = gr.Text(label="Describe your music", lines=2, interactive=True)
116
+ melody = gr.Audio(source="upload", type="numpy", label="Condition on a melody (optional)", interactive=True)
117
+ with gr.Row():
118
+ submit = gr.Button("Generate")
119
+ with gr.Column():
120
+ output = gr.Video(label="Generated Music")
121
+ submit.click(predict, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=8)
122
+ gr.Examples(
123
+ fn=predict,
124
+ examples=[
125
+ [
126
+ "An 80s driving pop song with heavy drums and synth pads in the background",
127
+ "./assets/bach.mp3",
128
+ ],
129
+ [
130
+ "A cheerful country song with acoustic guitars",
131
+ "./assets/bolero_ravel.mp3",
132
+ ],
133
+ [
134
+ "90s rock song with electric guitar and heavy drums",
135
+ None,
136
+ ],
137
+ [
138
+ "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
139
+ "./assets/bach.mp3",
140
+ ],
141
+ [
142
+ "lofi slow bpm electro chill with organic samples",
143
+ None,
144
+ ],
145
+ ],
146
+ inputs=[text, melody],
147
+ outputs=[output]
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
+ See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
160
+ for more details.
161
+ """)
162
+
163
+ demo.queue(max_size=8 * 4).launch()