Orientation for PyTorch users
OpenSoundscape uses PyTorch “under the hood” for machine learning tasks. If you’re familiar with PyTorch, these connections to the OpenSoundscape API should let you start using pieces of OpenSoundscape within your current workflows without much hacking:
AudioSplittingDatasetsubclass torch.dataset and include preprocessing and augmentation. If you use them as a drop-in substitution for a PyTorch Dataset, pay attention to your DataLoader’s
collate_fn. You can set the
opensoundscape.ml.utils.collate_audio_samples_to_tensorsto stack samples and labels with a leading batch dimension, as is typical in PyTorch.
.networkattribute is a PyTorch model object.
The CNN class implements high-level methods
.generate_cams()APIs which do what you expect them to
integration with the Weights and Biases logging platform is built-in; pass a wandb session object to
.predict()method, and get live sample logging and metrics
.preprocessorattribute (which becomes AudioFileDataset/AudioSplittingDataset’s
.predict()) defines a sequential series of preprocessing & augmentation actions performed on each sample. Specifically, preprocessor.pipeline is a pd.Series and each item is an instance of the
opensoundscape.preprocess.action.Actionclass (or subclass). See the preprocessing tutorial notebook for specifics on modifying preprocessing.