Demucs (code, paper)
Browse files- .gitattributes +6 -0
- Hybrid Transformers for Music Source Separation.pdf +3 -0
- Towards Reliable Objective Evaluation Metrics for Generative Singing Voice Separation Models.pdf +3 -0
- code/GUI/Demucs-Gui.zip +3 -0
- code/GUI/releases/v1.3.2.1/Demucs-Gui-1.3.2.1.zip +3 -0
- code/GUI/releases/v1.3.2.1/torch-blackwell-for-2.x.7z +3 -0
- code/GUI/releases/v1.3.2.1/torch-blackwell.7z +3 -0
- code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_cpu.7z +3 -0
- code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_cuda_mkl.7z +3 -0
- code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_macOS_ARM64.dmg +3 -0
- code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_macOS_x86_64_Rosetta2.dmg +3 -0
- code/GUI/releases/v1.3.2/Demucs-Gui-1.3.2.zip +3 -0
- code/GUI/releases/v1.3.2/Demucs_GUI-x86_64-1.3.2-cpu.tar +3 -0
- code/GUI/releases/v1.3.2/Demucs_GUI-x86_64-1.3.2-rocm.tar +3 -0
- code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_cpu.7z +3 -0
- code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_cuda_mkl.7z +3 -0
- code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_macOS_ARM64.dmg +3 -0
- code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_macOS_x86_64_Rosetta2.dmg +3 -0
- code/GUI/releases/v2.0a1/Demucs-Gui-2.0a1.zip +3 -0
- code/GUI/releases/v2.0a1/Demucs_GUI-x86_64-2.0a1-cpu.tar +3 -0
- code/GUI/releases/v2.0a1/Demucs_GUI-x86_64-2.0a1-cuda.tar +3 -0
- code/GUI/releases/v2.0a1/Demucs_GUI-x86_64-2.0a1-rocm.tar +3 -0
- code/demucs NEW [adefossez] +8 -6.zip +3 -0
- code/demucs [Ryan5453].zip +3 -0
- code/demucs-onnx.zip +3 -0
- code/demucs-vl [Huanshere] +3 -4 (Ryan5453 fork).zip +3 -0
- code/demucs.cpp.zip +3 -0
- code/demucs.zip +3 -0
- code/my_demucs.zip +3 -0
- colab/Hybrid_Demucs_Music_Source_Separation.ipynb +211 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,9 @@ saved_model/**/* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_macOS_ARM64.dmg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_macOS_x86_64_Rosetta2.dmg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_macOS_ARM64.dmg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_macOS_x86_64_Rosetta2.dmg filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
Hybrid[[:space:]]Transformers[[:space:]]for[[:space:]]Music[[:space:]]Source[[:space:]]Separation.pdf filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
Towards[[:space:]]Reliable[[:space:]]Objective[[:space:]]Evaluation[[:space:]]Metrics[[:space:]]for[[:space:]]Generative[[:space:]]Singing[[:space:]]Voice[[:space:]]Separation[[:space:]]Models.pdf filter=lfs diff=lfs merge=lfs -text
|
Hybrid Transformers for Music Source Separation.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7304d3b30cf26b9206ffc9081b6eec20c8e7fc0b16c9906a03a9749837787aa0
|
| 3 |
+
size 748688
|
Towards Reliable Objective Evaluation Metrics for Generative Singing Voice Separation Models.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:57210fafe805d18cd2a10260f3df55c111a1e35a3802040baea722eecbe0184a
|
| 3 |
+
size 300785
|
code/GUI/Demucs-Gui.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f80770c0e39839d50aecd7222f9725bb8f90d0c360017199c56e074bc3b96ddc
|
| 3 |
+
size 11032251
|
code/GUI/releases/v1.3.2.1/Demucs-Gui-1.3.2.1.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15769d8d301e68d849249558fffcbde00ebc1990f07eb8fa0191414a9f1735dc
|
| 3 |
+
size 2715652
|
code/GUI/releases/v1.3.2.1/torch-blackwell-for-2.x.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d06b1ac82415a7d5b5a093b9b16077658a05332b2f1519571da670b272acec2
|
| 3 |
+
size 1419713104
|
code/GUI/releases/v1.3.2.1/torch-blackwell.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7179c4c79d9d3101ea7a28617f89bc9bf8fca7e270375e578bfcede549016193
|
| 3 |
+
size 1419480565
|
code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_cpu.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:257ec12d8416f84b7392d21828d3711d2fdb7b32c5cd49bb9ef62485c2dd1b1b
|
| 3 |
+
size 234675938
|
code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_cuda_mkl.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eee577c0fa45c364dbd030dcf3842bee957091562a73a039db0a963c7fc31af8
|
| 3 |
+
size 1500900495
|
code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_macOS_ARM64.dmg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:effc8eeff2fb7fe33d98a3054a462ae37352e93dcd00cffd2b42cf50f6eed783
|
| 3 |
+
size 262364412
|
code/GUI/releases/v1.3.2/Demucs-GUI_1.3.2_macOS_x86_64_Rosetta2.dmg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:534ce8a90f67549d7bbba91c16f33406c55f0693e6b48a4c4976227d5a5aa7d9
|
| 3 |
+
size 386095184
|
code/GUI/releases/v1.3.2/Demucs-Gui-1.3.2.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61cc40518b6d3087ad32d42e73a515b52e404960776020aaaaf56f6cabba2532
|
| 3 |
+
size 2715492
|
code/GUI/releases/v1.3.2/Demucs_GUI-x86_64-1.3.2-cpu.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b9e8afa4be6d17d6331e8e3addf0d49cc70903067c5ff7540089071afdcd32f7
|
| 3 |
+
size 508712960
|
code/GUI/releases/v1.3.2/Demucs_GUI-x86_64-1.3.2-rocm.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05a505f292921650bde546742051468ac587e7d18e225b102581c68f7f1e9d8d
|
| 3 |
+
size 1366179840
|
code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_cpu.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f9f3fb1843e19425e229cd3b99565c3d33a29d8a10f572f3307d9140e3d2ac6
|
| 3 |
+
size 338161015
|
code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_cuda_mkl.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38ed94390ffa209e6eed5b786e670f43ff29ea0c021b6eee5af07115244375b9
|
| 3 |
+
size 1609436714
|
code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_macOS_ARM64.dmg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c4c1ee57a4a6f807be8fd9717304fbd635e70cc74a0b7c1e946351fc631675f
|
| 3 |
+
size 324740665
|
code/GUI/releases/v2.0a1/Demucs-GUI_2.0a1_macOS_x86_64_Rosetta2.dmg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2f3158aa1b0562a8974782e2312f0c471e6d0cf9120e092d8ed20d78757da17e
|
| 3 |
+
size 385076901
|
code/GUI/releases/v2.0a1/Demucs-Gui-2.0a1.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d158c867c1e300e485fca4b8cac309ddf59c7801967aaff1a945411823d76336
|
| 3 |
+
size 2725930
|
code/GUI/releases/v2.0a1/Demucs_GUI-x86_64-2.0a1-cpu.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bbcdc50dde78a91b7ead0ad7ce14df3c395f1aa5a43b9a5b74f489a6ed0682bf
|
| 3 |
+
size 657858560
|
code/GUI/releases/v2.0a1/Demucs_GUI-x86_64-2.0a1-cuda.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f42c6018b079deded9623f8aa2845e1d7b5a7ab8016182e135795ae44ad28ff
|
| 3 |
+
size 2391019520
|
code/GUI/releases/v2.0a1/Demucs_GUI-x86_64-2.0a1-rocm.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:87cfb9253bbf3e532dc2a74560e533166c3386f28449a697340ec55e1c632491
|
| 3 |
+
size 1515540480
|
code/demucs NEW [adefossez] +8 -6.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:931b0da7e25ad77ce0223245fb52dae412f208d6a94ef2e303f352b0ddd12321
|
| 3 |
+
size 81880486
|
code/demucs [Ryan5453].zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:580d5e9b2404265fa1d48009e248adc8f6f43b1842da974618d245b1df56c151
|
| 3 |
+
size 215833
|
code/demucs-onnx.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03202ea22d94a42141361eef0fc38dee620ac12efc9e8b3a8663254e748486d3
|
| 3 |
+
size 593118937
|
code/demucs-vl [Huanshere] +3 -4 (Ryan5453 fork).zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6199c58f31e362c536930b0e5203963eeabdd229c1d12a79a05c911a931f8e75
|
| 3 |
+
size 53099
|
code/demucs.cpp.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:addbfdfcc1014d326c655fa39cdf57a20d38abba1630a1bab65644c5e54d4653
|
| 3 |
+
size 296153711
|
code/demucs.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2e69685f19fcd52a77d56ae9d11d31d458141f5b3c31f1e78dd02231b3e6f7f
|
| 3 |
+
size 81902775
|
code/my_demucs.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0499013f06a3fdccc252062d69b3955f10948e27e169f315531355f039abafc
|
| 3 |
+
size 81891062
|
colab/Hybrid_Demucs_Music_Source_Separation.ipynb
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"nbformat": 4,
|
| 3 |
+
"nbformat_minor": 0,
|
| 4 |
+
"metadata": {
|
| 5 |
+
"colab": {
|
| 6 |
+
"provenance": []
|
| 7 |
+
},
|
| 8 |
+
"kernelspec": {
|
| 9 |
+
"name": "python3",
|
| 10 |
+
"display_name": "Python 3"
|
| 11 |
+
},
|
| 12 |
+
"language_info": {
|
| 13 |
+
"name": "python"
|
| 14 |
+
},
|
| 15 |
+
"accelerator": "GPU"
|
| 16 |
+
},
|
| 17 |
+
"cells": [
|
| 18 |
+
{
|
| 19 |
+
"cell_type": "markdown",
|
| 20 |
+
"metadata": {
|
| 21 |
+
"id": "uLghRcAdqaph"
|
| 22 |
+
},
|
| 23 |
+
"source": [
|
| 24 |
+
"# Hybrid Demucs from Colab\n",
|
| 25 |
+
"\n",
|
| 26 |
+
"This supports the Demucs source separation model (https://github.com/facebookresearch/demucs/)\n",
|
| 27 |
+
"This is only for separation with pre-trained models, not training!\n",
|
| 28 |
+
"\n",
|
| 29 |
+
"You can either upload files manually (slow) or link your Google Drive account."
|
| 30 |
+
]
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"cell_type": "code",
|
| 34 |
+
"metadata": {
|
| 35 |
+
"id": "79JbZGcAqX3p"
|
| 36 |
+
},
|
| 37 |
+
"source": [
|
| 38 |
+
"!python3 -m pip install -U git+https://github.com/facebookresearch/demucs#egg=demucs"
|
| 39 |
+
],
|
| 40 |
+
"execution_count": null,
|
| 41 |
+
"outputs": []
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"cell_type": "code",
|
| 45 |
+
"metadata": {
|
| 46 |
+
"id": "a-2p6OoOrOZK"
|
| 47 |
+
},
|
| 48 |
+
"source": [
|
| 49 |
+
"# Please BE VERY CAREFUL, this will link your entire drive.\n",
|
| 50 |
+
"# So don't edit code, except the one that says 'Customize the following options',\n",
|
| 51 |
+
"# or you might mess up your files.\n",
|
| 52 |
+
"# IF YOU DO NO WANT TO LINK DRIVE, please see below for an alternative!\n",
|
| 53 |
+
"from google.colab import drive\n",
|
| 54 |
+
"drive.mount('/gdrive')"
|
| 55 |
+
],
|
| 56 |
+
"execution_count": null,
|
| 57 |
+
"outputs": []
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"cell_type": "code",
|
| 61 |
+
"metadata": {
|
| 62 |
+
"id": "znCvBifRrO-b"
|
| 63 |
+
},
|
| 64 |
+
"source": [
|
| 65 |
+
"# Customize the following options!\n",
|
| 66 |
+
"model = \"htdemucs\"\n",
|
| 67 |
+
"extensions = [\"mp3\", \"wav\", \"ogg\", \"flac\"] # we will look for all those file types.\n",
|
| 68 |
+
"two_stems = None # only separate one stems from the rest, for instance\n",
|
| 69 |
+
"# two_stems = \"vocals\"\n",
|
| 70 |
+
"\n",
|
| 71 |
+
"# Options for the output audio.\n",
|
| 72 |
+
"mp3 = True\n",
|
| 73 |
+
"mp3_rate = 320\n",
|
| 74 |
+
"float32 = False # output as float 32 wavs, unsused if 'mp3' is True.\n",
|
| 75 |
+
"int24 = False # output as int24 wavs, unused if 'mp3' is True.\n",
|
| 76 |
+
"# You cannot set both `float32 = True` and `int24 = True` !!\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"in_path = '/gdrive/MyDrive/demucs/'\n",
|
| 79 |
+
"out_path = '/gdrive/MyDrive/demucs_separated/'"
|
| 80 |
+
],
|
| 81 |
+
"execution_count": null,
|
| 82 |
+
"outputs": []
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"cell_type": "code",
|
| 86 |
+
"metadata": {
|
| 87 |
+
"id": "kMKN9BN4r37E",
|
| 88 |
+
"cellView": "form"
|
| 89 |
+
},
|
| 90 |
+
"source": [
|
| 91 |
+
"#@title Useful functions, don't forget to execute\n",
|
| 92 |
+
"import io\n",
|
| 93 |
+
"from pathlib import Path\n",
|
| 94 |
+
"import select\n",
|
| 95 |
+
"from shutil import rmtree\n",
|
| 96 |
+
"import subprocess as sp\n",
|
| 97 |
+
"import sys\n",
|
| 98 |
+
"from typing import Dict, Tuple, Optional, IO\n",
|
| 99 |
+
"\n",
|
| 100 |
+
"from google.colab import files\n",
|
| 101 |
+
"\n",
|
| 102 |
+
"def find_files(in_path):\n",
|
| 103 |
+
" out = []\n",
|
| 104 |
+
" for file in Path(in_path).iterdir():\n",
|
| 105 |
+
" if file.suffix.lower().lstrip(\".\") in extensions:\n",
|
| 106 |
+
" out.append(file)\n",
|
| 107 |
+
" return out\n",
|
| 108 |
+
"\n",
|
| 109 |
+
"def copy_process_streams(process: sp.Popen):\n",
|
| 110 |
+
" def raw(stream: Optional[IO[bytes]]) -> IO[bytes]:\n",
|
| 111 |
+
" assert stream is not None\n",
|
| 112 |
+
" if isinstance(stream, io.BufferedIOBase):\n",
|
| 113 |
+
" stream = stream.raw\n",
|
| 114 |
+
" return stream\n",
|
| 115 |
+
"\n",
|
| 116 |
+
" p_stdout, p_stderr = raw(process.stdout), raw(process.stderr)\n",
|
| 117 |
+
" stream_by_fd: Dict[int, Tuple[IO[bytes], io.StringIO, IO[str]]] = {\n",
|
| 118 |
+
" p_stdout.fileno(): (p_stdout, sys.stdout),\n",
|
| 119 |
+
" p_stderr.fileno(): (p_stderr, sys.stderr),\n",
|
| 120 |
+
" }\n",
|
| 121 |
+
" fds = list(stream_by_fd.keys())\n",
|
| 122 |
+
"\n",
|
| 123 |
+
" while fds:\n",
|
| 124 |
+
" # `select` syscall will wait until one of the file descriptors has content.\n",
|
| 125 |
+
" ready, _, _ = select.select(fds, [], [])\n",
|
| 126 |
+
" for fd in ready:\n",
|
| 127 |
+
" p_stream, std = stream_by_fd[fd]\n",
|
| 128 |
+
" raw_buf = p_stream.read(2 ** 16)\n",
|
| 129 |
+
" if not raw_buf:\n",
|
| 130 |
+
" fds.remove(fd)\n",
|
| 131 |
+
" continue\n",
|
| 132 |
+
" buf = raw_buf.decode()\n",
|
| 133 |
+
" std.write(buf)\n",
|
| 134 |
+
" std.flush()\n",
|
| 135 |
+
"\n",
|
| 136 |
+
"def separate(inp=None, outp=None):\n",
|
| 137 |
+
" inp = inp or in_path\n",
|
| 138 |
+
" outp = outp or out_path\n",
|
| 139 |
+
" cmd = [\"python3\", \"-m\", \"demucs.separate\", \"-o\", str(outp), \"-n\", model]\n",
|
| 140 |
+
" if mp3:\n",
|
| 141 |
+
" cmd += [\"--mp3\", f\"--mp3-bitrate={mp3_rate}\"]\n",
|
| 142 |
+
" if float32:\n",
|
| 143 |
+
" cmd += [\"--float32\"]\n",
|
| 144 |
+
" if int24:\n",
|
| 145 |
+
" cmd += [\"--int24\"]\n",
|
| 146 |
+
" if two_stems is not None:\n",
|
| 147 |
+
" cmd += [f\"--two-stems={two_stems}\"]\n",
|
| 148 |
+
" files = [str(f) for f in find_files(inp)]\n",
|
| 149 |
+
" if not files:\n",
|
| 150 |
+
" print(f\"No valid audio files in {in_path}\")\n",
|
| 151 |
+
" return\n",
|
| 152 |
+
" print(\"Going to separate the files:\")\n",
|
| 153 |
+
" print('\\n'.join(files))\n",
|
| 154 |
+
" print(\"With command: \", \" \".join(cmd))\n",
|
| 155 |
+
" p = sp.Popen(cmd + files, stdout=sp.PIPE, stderr=sp.PIPE)\n",
|
| 156 |
+
" copy_process_streams(p)\n",
|
| 157 |
+
" p.wait()\n",
|
| 158 |
+
" if p.returncode != 0:\n",
|
| 159 |
+
" print(\"Command failed, something went wrong.\")\n",
|
| 160 |
+
"\n",
|
| 161 |
+
"\n",
|
| 162 |
+
"def from_upload():\n",
|
| 163 |
+
" out_path = Path('separated')\n",
|
| 164 |
+
" in_path = Path('tmp_in')\n",
|
| 165 |
+
"\n",
|
| 166 |
+
" if in_path.exists():\n",
|
| 167 |
+
" rmtree(in_path)\n",
|
| 168 |
+
" in_path.mkdir()\n",
|
| 169 |
+
"\n",
|
| 170 |
+
" if out_path.exists():\n",
|
| 171 |
+
" rmtree(out_path)\n",
|
| 172 |
+
" out_path.mkdir()\n",
|
| 173 |
+
"\n",
|
| 174 |
+
" uploaded = files.upload()\n",
|
| 175 |
+
" for name, content in uploaded.items():\n",
|
| 176 |
+
" (in_path / name).write_bytes(content)\n",
|
| 177 |
+
" separate(in_path, out_path)\n"
|
| 178 |
+
],
|
| 179 |
+
"execution_count": null,
|
| 180 |
+
"outputs": []
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"cell_type": "code",
|
| 184 |
+
"metadata": {
|
| 185 |
+
"id": "gr9OJvf-tYyt"
|
| 186 |
+
},
|
| 187 |
+
"source": [
|
| 188 |
+
"# This can be quite slow, in particular the loading, and saving from GDrive. Please be patient!\n",
|
| 189 |
+
"# This is from google drive! Also, this will separate all the files inside the MyDrive/demucs folder,\n",
|
| 190 |
+
"# so when you are happy with the results, remove the songs from there.\n",
|
| 191 |
+
"separate()"
|
| 192 |
+
],
|
| 193 |
+
"execution_count": null,
|
| 194 |
+
"outputs": []
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"cell_type": "code",
|
| 198 |
+
"metadata": {
|
| 199 |
+
"id": "v__3gMJawTD0"
|
| 200 |
+
},
|
| 201 |
+
"source": [
|
| 202 |
+
"# This is manual upload and download :)\n",
|
| 203 |
+
"from_upload()\n",
|
| 204 |
+
"!zip -r separated.zip separated\n",
|
| 205 |
+
"files.download('./separated.zip')"
|
| 206 |
+
],
|
| 207 |
+
"execution_count": null,
|
| 208 |
+
"outputs": []
|
| 209 |
+
}
|
| 210 |
+
]
|
| 211 |
+
}
|