add MusicGen option
Browse files
app.py
CHANGED
@@ -158,6 +158,16 @@ def get_mustango(prompt):
|
|
158 |
)
|
159 |
print(result)
|
160 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
import re
|
163 |
import torch
|
@@ -239,6 +249,9 @@ def infer(image_in, chosen_model, api_status):
|
|
239 |
elif chosen_model == "Mustango" :
|
240 |
gr.Info("Now calling Mustango for music...")
|
241 |
music_o = get_mustango(musical_prompt)
|
|
|
|
|
|
|
242 |
|
243 |
return gr.update(value=musical_prompt, interactive=True), gr.update(visible=True), music_o
|
244 |
|
@@ -257,11 +270,14 @@ def retry(chosen_model, caption):
|
|
257 |
elif chosen_model == "Mustango" :
|
258 |
gr.Info("Now calling Mustango for music...")
|
259 |
music_o = get_mustango(musical_prompt)
|
|
|
|
|
|
|
260 |
|
261 |
return music_o
|
262 |
|
263 |
demo_title = "Image to Music V2"
|
264 |
-
description = "Get music from a picture"
|
265 |
|
266 |
css = """
|
267 |
#col-container {
|
@@ -302,7 +318,8 @@ with gr.Blocks(css=css) as demo:
|
|
302 |
"MAGNet",
|
303 |
"AudioLDM-2",
|
304 |
"Riffusion",
|
305 |
-
"Mustango"
|
|
|
306 |
],
|
307 |
value = None,
|
308 |
filterable = False
|
|
|
158 |
)
|
159 |
print(result)
|
160 |
return result
|
161 |
+
|
162 |
+
def get_musicgen(prompt):
|
163 |
+
client = Client("https://facebook-musicgen.hf.space/")
|
164 |
+
result = client.predict(
|
165 |
+
prompt, # str in 'Describe your music' Textbox component
|
166 |
+
None, # str (filepath or URL to file) in 'File' Audio component
|
167 |
+
fn_index=0
|
168 |
+
)
|
169 |
+
print(result)
|
170 |
+
return result[1]
|
171 |
|
172 |
import re
|
173 |
import torch
|
|
|
249 |
elif chosen_model == "Mustango" :
|
250 |
gr.Info("Now calling Mustango for music...")
|
251 |
music_o = get_mustango(musical_prompt)
|
252 |
+
elif chosen_model == "MusicGen" :
|
253 |
+
gr.Info("Now calling MusicGen for music...")
|
254 |
+
music_o = get_musicgen(musical_prompt)
|
255 |
|
256 |
return gr.update(value=musical_prompt, interactive=True), gr.update(visible=True), music_o
|
257 |
|
|
|
270 |
elif chosen_model == "Mustango" :
|
271 |
gr.Info("Now calling Mustango for music...")
|
272 |
music_o = get_mustango(musical_prompt)
|
273 |
+
elif chosen_model == "MusicGen" :
|
274 |
+
gr.Info("Now calling MusicGen for music...")
|
275 |
+
music_o = get_musicgen(musical_prompt)
|
276 |
|
277 |
return music_o
|
278 |
|
279 |
demo_title = "Image to Music V2"
|
280 |
+
description = "Get music from a picture, compare text-to-music models"
|
281 |
|
282 |
css = """
|
283 |
#col-container {
|
|
|
318 |
"MAGNet",
|
319 |
"AudioLDM-2",
|
320 |
"Riffusion",
|
321 |
+
"Mustango",
|
322 |
+
"MusicGen"
|
323 |
],
|
324 |
value = None,
|
325 |
filterable = False
|