This repository contains some tutorials on machine learning using JupyterLab notebook and PyTorch.
inference-cpp
: code for the c++ inference applicationnotebooks
: Jupyter notebooks containing the tutorials (including code)0_intro_machine_learning.ipynb
: Basic introduction to machine learning1_pytorch_basic.ipynb
: Train a simple neural network to learn a line equation2_pytorch_advanced.ipynb
: Train an audio classification model using transfer learning
train
: default training directory (used to saved trained model and spectrogram config)test/data
: directory containing some audio files used for testing
First, you neeed to clone this repository. Make sure to include the submodule(s) when cloning by running
git clone --recurse-submodules https://stash.steinberg-intra.net/scm/~lhannink/intro-ml-with-pytorch.git
In case you did a bare clone
without the submodule flag, run
git submodule sync
git submodule update --init --recursive
to download the submodules for an existing checkout.
In order to run the tutorial notebooks and build the C++ application, you need to have the following stuff installed on your system:
cmake
+ supported build system for your platform (Ninja, Make, VS, Xcode, ...)- Python 3.8
pipenv
If you don't have Python 3.8 and pipenv
installed have a look at INSTALLING_PYTHON.md.
The tutorial notebooks are intended to be run from within a Python virtual environment.
Open up a terminal in the directory of this repository and run
pipenv install
to automatically create a new virtual environment using the correct Python version and install the package dependencies.
Unfortunately, installing PyTorch through pipenv
is not possible at the
moment due to a bug, so we will have to use raw pip
to install it:
Install this if you don't know if you have a CUDA-capable GPU. The training will be slower using the CPU version but there is no additional setup required.
pipenv run pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.1 -f https://download.pytorch.org/whl/torch_stable.html
pipenv run pip install fastai==2.1.9 fastaudio==0.1.4
If you have a CUDA-capable GPU and have a working CUDA 11.0 installation (including corresponding cuDNN version), you can install the CUDA-enabled version:
pipenv run pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.1 -f https://download.pytorch.org/whl/torch_stable.html
pipenv run pip install fastai==2.1.9 fastaudio==0.1.4
Start the JupyterLab server inside of your new virtual environment by running
pipenv run jupyter lab
still inside the directory of this repo.
A new instance of the Juypter server will be started and automatically open up the JupyterLab start page in your browser. We will only be interacting with the browser front-end from now on but you need to leave the server running in the background.
Using the file browser in the left pane, navigate into the notebooks/
directory and open up the first .ipynb
file.
This repository contains some sounds from freesound.org
for testing purposes. The following sounds have been used:
- https://freesound.org/people/AurelioSons/sounds/207457/
- https://freesound.org/people/InspectorJ/sounds/368804/
- https://freesound.org/people/InspectorJ/sounds/404329/
- https://freesound.org/people/Juan_Merie_Venter/sounds/327666/
- https://freesound.org/people/zachrau/sounds/362283/
- https://freesound.org/people/Teumova/sounds/439667/
- https://freesound.org/people/Masgame/sounds/347544/
- https://freesound.org/people/Kingrock2009/sounds/544376/
- https://freesound.org/people/Acekat13/sounds/515685/
- https://freesound.org/people/pryght%20one/sounds/27130/
- https://freesound.org/people/Erokia/sounds/550708/