Last active
August 13, 2023 14:07
-
-
Save sevagh/9f22d25bef20a79a1ab3ba57b0f88739 to your computer and use it in GitHub Desktop.
create newproj.cpp (oriented for music demixing projects e.g. demucs.cpp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# script for bootstrapping an '$mdx.cpp' project | |
# mdx = music demixing | |
# e.g. umx.cpp (open-unmix) | |
# demucs.cpp (Demucs) | |
set -Eou pipefail | |
set -x | |
original="git@github.com:sevagh/umx.cpp" | |
demixproj="demucs" | |
clonedname="demucs" | |
projsubmodule="-b release_v4 https://github.com/facebookresearch/demucs ${clonedname}" | |
cppproj="${demixproj}.cpp" | |
reporoot="git@github.com:sevagh/${cppproj}" | |
# clone umx.cpp into newproj.cpp | |
git clone ${original} ${cppproj} && cd ${cppproj} | |
rm -rf .git | |
rm -rf ./vendor | |
git init && git remote add origin ${reporoot} | |
mkdir -p vendor && cd vendor && \ | |
git submodule add https://gitlab.com/libeigen/eigen && \ | |
git submodule add https://github.com/ddiakopoulos/libnyquist && \ | |
git submodule add ${projsubmodule} && \ | |
cd - | |
cat > README.md <<EOF | |
New project: ${cppproj} | |
This is the ${cppproj} project, created from umx.cpp using <https://gist.github.com/sevagh/9f22d25bef20a79a1ab3ba57b0f88739> | |
Work left to the creator: | |
Python scripts: | |
- Modify scripts/${demixproj}_pytorch_inference.py to use new model | |
- Modify scripts/convert-pth-to-ggml.py to fit new model | |
C++ code: | |
- Modify src/model.cpp,hpp | |
- Delete src/lstm.cpp,hpp if you don't need it | |
- Modify src/tensor.hpp to support your needed dimensions | |
- Modify ./${cppproj} to use new C++ model | |
- [OPTIONAL] Add more tests in tests/ | |
EOF | |
pipproj="-e ./vendor/${clonedname}" | |
sed -i -e "s/openunmix/${demixproj}/g" \ | |
-e "s#-e ./vendor/open-unmix-pytorch#-e ./vendor/${clonedname}#g" \ | |
-e '/^#openunmix==.*/d' \ | |
./scripts/requirements.txt | |
rm scripts/compare-torch-stft.py | |
mv scripts/umx_pytorch_inference.py "scripts/${demixproj}_pytorch_inference.py" | |
sed -i '/import openunmix/d' scripts/evaluate-demixed-output.py | |
mv umx.cpp ./${cppproj} | |
sed -i "s/umx\.cpp/${cppproj}/g" CMakeLists.txt | |
git add -A && git commit -m "Create ${cppproj} from umx.cpp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment