vpavlenko taejunkim commited on
Commit
af8e0fa
·
0 Parent(s):

Duplicate from taejunkim/all-in-one

Browse files

Co-authored-by: Taejun Kim <[email protected]>

.gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ demix/
2
+ sonif/
3
+ spec/
4
+ flagged/
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: All In One
3
+ emoji: 📊
4
+ colorFrom: pink
5
+ colorTo: gray
6
+ sdk: gradio
7
+ python_version: 3.1
8
+ sdk_version: 3.42.0
9
+ app_file: app.py
10
+ pinned: false
11
+ license: mit
12
+ duplicated_from: taejunkim/all-in-one
13
+ ---
app.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import allin1
4
+
5
+ from pathlib import Path
6
+
7
+ HEADER = """
8
+ <header style="text-align: center;">
9
+ <h1>
10
+ All-In-One Music Structure Analyzer 🔮
11
+ </h1>
12
+ <p>
13
+ <a href="https://github.com/mir-aidj/all-in-one">[Python Package]</a>
14
+ <a href="https://arxiv.org/abs/2307.16425">[Paper]</a>
15
+ <a href="https://taejun.kim/music-dissector/">[Visual Demo]</a>
16
+ </p>
17
+ </header>
18
+ <main
19
+ style="display: flex; justify-content: center;"
20
+ >
21
+ <div
22
+ style="display: inline-block;"
23
+ >
24
+ <p>
25
+ This Space demonstrates the music structure analyzer predicts:
26
+ <ul
27
+ style="padding-left: 1rem;"
28
+ >
29
+ <li>BPM</li>
30
+ <li>Beats</li>
31
+ <li>Downbeats</li>
32
+ <li>Functional segment boundaries</li>
33
+ <li>Functional segment labels (e.g. intro, verse, chorus, bridge, outro)</li>
34
+ </ul>
35
+ </p>
36
+ <p>
37
+ It takes about 4:30 to analyze a 3-minute song.
38
+ If you are in a hurry, you can <strong><u>try the examples at the bottom</u></strong>.
39
+ </p>
40
+ <p>
41
+ For more information, please visit the links above ✨🧸
42
+ </p>
43
+ </div>
44
+ </main>
45
+ """
46
+
47
+ CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
48
+
49
+
50
+ def analyze(path):
51
+ path = Path(path)
52
+ result = allin1.analyze(
53
+ path,
54
+ multiprocess=False,
55
+ keep_byproducts=True, # TODO: remove this
56
+ )
57
+
58
+ fig = allin1.visualize(result)
59
+ fig.set_dpi(300)
60
+
61
+ allin1.sonify(result, out_dir='./sonif')
62
+ sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
63
+
64
+ return result.bpm, fig, sonif_path
65
+
66
+
67
+ with gr.Blocks() as demo:
68
+ gr.HTML(HEADER)
69
+
70
+ input_audio_path = gr.Audio(
71
+ label='Input',
72
+ source='upload',
73
+ type='filepath',
74
+ format='mp3',
75
+ show_download_button=False,
76
+ )
77
+ button = gr.Button('Analyze', variant='primary')
78
+ output_viz = gr.Plot(label='Visualization')
79
+ with gr.Row():
80
+ output_bpm = gr.Textbox(label='BPM', scale=1)
81
+ output_sonif = gr.Audio(
82
+ label='Sonification',
83
+ type='filepath',
84
+ format='mp3',
85
+ show_download_button=False,
86
+ scale=9,
87
+ )
88
+ gr.Examples(
89
+ examples=[
90
+ './assets/NewJeans - Super Shy.mp3',
91
+ './assets/Bruno Mars - 24k Magic.mp3'
92
+ ],
93
+ inputs=input_audio_path,
94
+ outputs=[output_bpm, output_viz, output_sonif],
95
+ fn=analyze,
96
+ cache_examples=CACHE_EXAMPLES,
97
+ )
98
+ button.click(
99
+ fn=analyze,
100
+ inputs=input_audio_path,
101
+ outputs=[output_bpm, output_viz, output_sonif],
102
+ api_name='analyze',
103
+ )
104
+
105
+ if __name__ == '__main__':
106
+ demo.launch()
assets/Bruno Mars - 24k Magic.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ea22c9cfd343380c2ab7794a6f060513f63e8ff2367222b86b430aa5d20b224
3
+ size 9115872
assets/NewJeans - Super Shy.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5b6e0015079814088a34633db74aa1e6e9435fdaa8a4633d5b730b5165dad36
3
+ size 6398696
pre-requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cpu
2
+ torch==2.0.1
3
+ torchaudio
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ -f https://shi-labs.com/natten/wheels/cpu/torch2.0.0/index.html
2
+ natten
3
+ madmom @ git+https://github.com/CPJKU/madmom
4
+ allin1
5
+ gradio