Please install docker and the nvidia-docker following instructions at https://github.com/NVIDIA/nvidia-docker (namely here: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker )
xhost +SI:localuser:root
sudo docker run -it --rm --privileged=true --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env="QT_X11_NO_MITSHM=1" -v $(pwd)/data/:/home/music_gen_interaction_RTML/data/ --gpus all --device=/dev/snd:/dev/snd previtus/demo-lstm-music-gen
xhost -SI:localuser:root
xhost +SI:localuser:root
sudo docker run -it --rm --privileged=true --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env="QT_X11_NO_MITSHM=1" -v "$(pwd)/data/":/home/music_gen_interaction_RTML/data/ -v "$(pwd)/__custom_saved_models/":/home/music_gen_interaction_RTML/__saved_models/ -v "$(pwd)/__custom_music_samples/":/home/music_gen_interaction_RTML/__music_samples/ --gpus all --device=/dev/snd:/dev/snd previtus/demo-lstm-music-gen
xhost -SI:localuser:root
First place your wav file into "__custom_music_samples/sample/ccastles.wav" (replace "ccastles.wav" with your file name) and then run:
xhost +SI:localuser:root
sudo docker run -it --rm --privileged=true --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env="QT_X11_NO_MITSHM=1" -v "$(pwd)/data/":/home/music_gen_interaction_RTML/data/ -v "$(pwd)/__custom_saved_models/":/home/music_gen_interaction_RTML/__saved_models/ -v "$(pwd)/__custom_music_samples/":/home/music_gen_interaction_RTML/__music_samples/ --gpus all --device=/dev/snd:/dev/snd previtus/demo-lstm-music-gen python training_handler.py -target_file __music_samples/sample/ccastles.wav -amount_epochs 300 -batch_size 64
xhost -SI:localuser:root
Ps: you can also end with previtus/demo-lstm-music-gen python training_handler.py --help to see all available settings for the trained model (number of layers, hidden units and training settings, etc.)
Ps2: You will be able to see the trained model in the "__custom_saved_models/" folder. (Important!) Do not rename the model files (namely do not remove the "Model_" from the name - there are some checks that need it present)...
# Note: Make sure that nvidia Docker is installed. We can test it with:
# sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
# We need to get the sound sample - provide your own mp3 (and convert it to wav) / wav / or let's download a demo
#ffmpeg -i sample.mp3 sample.wav
#wget -O sample.wav https://www2.cs.uic.edu/~i101/SoundFiles/StarWars60.wav
# Let's assume that we have a file called "sample.wav" in the current directory
# Prepare folders (these will be shared with the script inside Docker - and allow us to send the music sample in and then get the final model out)
mkdir __custom_music_samples
mkdir __custom_music_samples/sample
cp sample.wav __custom_music_samples/sample/
mkdir __custom_saved_models
mkdir data
# Docker root rights
xhost +SI:localuser:root
# (Optionally) Let's try the basic functionality (command from Step 1) - this might take couple of minutes, but should end up playing a sound
# Note1: Jackd binding sometimes has some issues if there is any other sound playing, so please stop it before running this demo
# Note2: Exit with ctrl-c
# sudo docker run -it --rm --privileged=true --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env="QT_X11_NO_MITSHM=1" -v $(pwd)/data/:/home/music_gen_interaction_RTML/data/ --gpus all --device=/dev/snd:/dev/snd previtus/demo-lstm-music-gen
# Train a model on our sample (this is a command from Step 3 with slightly altered path)
# Note: Training a model will take some time (also depending on the number of epochs we selected) and in the end will save the model files into the "__custom_saved_models" directory (which is available outside of the Docker).
sudo docker run -it --rm --privileged=true --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env="QT_X11_NO_MITSHM=1" -v "$(pwd)/data/":/home/music_gen_interaction_RTML/data/ -v "$(pwd)/__custom_saved_models/":/home/music_gen_interaction_RTML/__saved_models/ -v "$(pwd)/__custom_music_samples/":/home/music_gen_interaction_RTML/__music_samples/ --gpus all --device=/dev/snd:/dev/snd previtus/demo-lstm-music-gen python training_handler.py -target_file __music_samples/sample/sample.wav -amount_epochs 300 -batch_size 64
# (Important!) Do not rename the model files (namely do not remove the "Model_" from the name - there are some checks that need it present)...
# Now we can finally run the trained model in real-time:
# Note: you don't have to change any path in this command - it will simply select the trained model and the source audio file from the prepared folders.
# Note2: Exit with ctrl-c
sudo docker run -it --rm --privileged=true --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env="QT_X11_NO_MITSHM=1" -v "$(pwd)/data/":/home/music_gen_interaction_RTML/data/ -v "$(pwd)/__custom_saved_models/":/home/music_gen_interaction_RTML/__saved_models/ -v "$(pwd)/__custom_music_samples/":/home/music_gen_interaction_RTML/__music_samples/ --gpus all --device=/dev/snd:/dev/snd previtus/demo-lstm-music-gen
# And that's it!
# If you want to have a higher quality model, a larger number of epochs is suggested - try starting with 300. You can also adjust the batch size (as a rule of thumb the bigger the better (and also faster to train) as long as your GPU's memory can take it) or further play with the model architecture.
xhost -SI:localuser:root
If you are looking for the simplest possible one-click bash file, check out this one: https://gist.github.com/previtus/fc014f3aa27b13a077e37c598d7e65af
Content type
Image
Digest
Size
3.7 GB
Last updated
over 6 years ago
docker pull previtus/demo-lstm-music-gen