Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -3,8 +3,6 @@ import os
|
|
3 |
import numpy as np
|
4 |
|
5 |
def no_cpu_warning(video_file, dataset, lora, size):
|
6 |
-
gr.Warning("This interface is running on CPU. Only cached examples are displayed here, no new music can be generated.")
|
7 |
-
|
8 |
output = "./cached_examples/"
|
9 |
output += "peft" if lora else "audiocraft"
|
10 |
output += "_" + dataset + "_" + size + "_" + video_file[-7:-4]
|
@@ -13,38 +11,44 @@ def no_cpu_warning(video_file, dataset, lora, size):
|
|
13 |
|
14 |
if not os.path.exists(output):
|
15 |
print(output)
|
16 |
-
raise gr.Error("This combination of video and model has not been cached.
|
17 |
|
|
|
18 |
print("Displaying video: " + output)
|
19 |
return output
|
20 |
|
21 |
interface = gr.Interface(fn=no_cpu_warning,
|
22 |
inputs=[
|
23 |
gr.Video(value="videos/n_5.mp4",
|
24 |
-
label="Video
|
25 |
min_length=5,
|
26 |
max_length=20,
|
27 |
-
sources=[
|
28 |
show_download_button=True,
|
29 |
-
include_audio=True
|
|
|
|
|
30 |
gr.Radio(["nature", "symmv"],
|
31 |
value="nature",
|
32 |
label="Available Models",
|
33 |
-
info="Choose one of the
|
|
|
34 |
gr.Radio([False, True],
|
35 |
label="Use the LoRA version of the MusicGen Audio Decoder",
|
36 |
value=False,
|
37 |
info="If set to 'True' the MusicGen Audio Decoder models trained with LoRA "
|
38 |
"(Low Rank Adaptation) are used. If set to 'False', the original "
|
39 |
-
"MusicGen models are used instead."
|
|
|
40 |
gr.Radio(["small", "medium", "large"],
|
41 |
label="Model Size",
|
42 |
value="large",
|
43 |
-
info="Choose one of the available model sizes. The larger models are more likely produce "
|
44 |
-
"results of higher audio quality, but also take more time to generate it."
|
|
|
45 |
],
|
46 |
|
47 |
-
outputs=[gr.Video(label="
|
48 |
examples=[
|
49 |
[os.path.abspath("./videos/n_1.mp4"), "nature", False, "large"],
|
50 |
[os.path.abspath("./videos/n_2.mp4"), "nature", False, "large"],
|
@@ -63,10 +67,11 @@ interface = gr.Interface(fn=no_cpu_warning,
|
|
63 |
[os.path.abspath("./videos/s_7.mp4"), "symmv", True, "large"],
|
64 |
[os.path.abspath("./videos/s_8.mp4"), "symmv", True, "large"],
|
65 |
],
|
|
|
66 |
cache_examples=False,
|
67 |
)
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
interface.launch(
|
71 |
-
share=
|
72 |
)
|
|
|
3 |
import numpy as np
|
4 |
|
5 |
def no_cpu_warning(video_file, dataset, lora, size):
|
|
|
|
|
6 |
output = "./cached_examples/"
|
7 |
output += "peft" if lora else "audiocraft"
|
8 |
output += "_" + dataset + "_" + size + "_" + video_file[-7:-4]
|
|
|
11 |
|
12 |
if not os.path.exists(output):
|
13 |
print(output)
|
14 |
+
raise gr.Error("This combination of video and model has not been cached. Try one of the listed examples below instead.")
|
15 |
|
16 |
+
gr.Warning("This interface is running on CPU. Only cached examples are displayed here, no novel music is generated. Please be patient, as the videos meight take a while to be downloaded.")
|
17 |
print("Displaying video: " + output)
|
18 |
return output
|
19 |
|
20 |
interface = gr.Interface(fn=no_cpu_warning,
|
21 |
inputs=[
|
22 |
gr.Video(value="videos/n_5.mp4",
|
23 |
+
label="Original Video",
|
24 |
min_length=5,
|
25 |
max_length=20,
|
26 |
+
sources=[],
|
27 |
show_download_button=True,
|
28 |
+
include_audio=True,
|
29 |
+
mirror_webcam=False
|
30 |
+
),
|
31 |
gr.Radio(["nature", "symmv"],
|
32 |
value="nature",
|
33 |
label="Available Models",
|
34 |
+
info="Choose one of the datasets on which the models has been trained on. Nature is a dataset of calm and relaxing sounds, symmv contains charts music. The model will generate audio that is similar to the training data."
|
35 |
+
),
|
36 |
gr.Radio([False, True],
|
37 |
label="Use the LoRA version of the MusicGen Audio Decoder",
|
38 |
value=False,
|
39 |
info="If set to 'True' the MusicGen Audio Decoder models trained with LoRA "
|
40 |
"(Low Rank Adaptation) are used. If set to 'False', the original "
|
41 |
+
"MusicGen models are used instead."
|
42 |
+
),
|
43 |
gr.Radio(["small", "medium", "large"],
|
44 |
label="Model Size",
|
45 |
value="large",
|
46 |
+
info="Choose one of the available model sizes. This effects the enocder and the deocder model. The larger models are more likely produce "
|
47 |
+
"results of higher audio quality, but also take more time to generate it."
|
48 |
+
),
|
49 |
],
|
50 |
|
51 |
+
outputs=[gr.Video(label="Generated Result")],
|
52 |
examples=[
|
53 |
[os.path.abspath("./videos/n_1.mp4"), "nature", False, "large"],
|
54 |
[os.path.abspath("./videos/n_2.mp4"), "nature", False, "large"],
|
|
|
67 |
[os.path.abspath("./videos/s_7.mp4"), "symmv", True, "large"],
|
68 |
[os.path.abspath("./videos/s_8.mp4"), "symmv", True, "large"],
|
69 |
],
|
70 |
+
examples_per_page=20,
|
71 |
cache_examples=False,
|
72 |
)
|
73 |
|
74 |
if __name__ == "__main__":
|
75 |
interface.launch(
|
76 |
+
share=False
|
77 |
)
|