rainloreley / lofi-ML

Program to generate Lofi music using Machine Learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lofi ML

This program will train a machine learning model to generate Lofi music

This is just an experiment, don't use that music to study. It's shit

Based on the work from Skuldur and this article

Setup

  1. Install and setup Anaconda on your system
CPU version
  1. Run conda create -n tensorflow_env tensorflow
  2. Run conda activate tensorflow_env
GPU version
  1. conda create -n tensorflow_gpuenv tensorflow-gpu
  2. conda activate tensorflow_gpuenv
----- 4. Install missing dependencies (TBD, too lazy to do now)

Install training MIDI files

Prepare a dataset of MIDI files you want to use for training.

Create a new folder called trainingmidis and copy the MIDIs into it.

You can find a set of Lofi MIDIs here

Run training

python3 main.py train

Available parameters:

  • --epochs=: Set the amount of epochs the model will run through (Default: 200)
  • --batchsize=: Set the batch size for each epoch (Default: 64)

After the training, the program will find the best model and copy its weight file into the bestmodels directory.

During the training, the model will take checkpoints and save them to modelcheckpoints/{ISO 8601 datetime}/, so you can stop training whenever you like. This means the program won't find the best model, you have to do that manually.

Generate music

python3 main.py gen --weightfile={path}

Replace {path} with the path to your model weightfile

Available parameters:

  • notes=: Set the amount of notes to be generated (Default: 100)

Debug

TensorFlow can't allocate enough resources (GPU only)

Run export TF_FORCE_GPU_ALLOW_GROWTH='true'

The model only generates one repeating note

Experiment with the amount of epochs and batch size for training. Loss values < 0.1 seem to work

About

Program to generate Lofi music using Machine Learning

License:MIT License


Languages

Language:Python 100.0%