Base Classes

Base classes of this project.

Defines common interfaces, attributes, and utilities for different tasks.

Transcription

class omnizart.base.BaseTranscription(setting_class, conf_path=None)

Base class of transcription applications.

Methods

get_model(settings)

Get the model from the python source file.

transcribe

get_model(settings)

Get the model from the python source file.

This is only for those customized models that can’t export arch.yaml file, and hence need to instanitiate the model from python class, which is not that desirable as the architecture is not recorded in a stand-alone file.

Another way is using model.save() method to export .pb format architecture file, but there could be troubles if you want continue to train on these models in such format when these are customized models.

Returns
model: tf.keras.Model

The initialized keras model.

Label

class omnizart.base.Label(start_time, end_time, note, instrument=0, velocity=64, start_beat=0, end_beat=10, note_value='', is_drum=False)

Interface of different label format.

Plays the role for generalize the label format, and subsequent dataset class should implement functions transforming labels (whether in .mid, .txt, or .csv format) and parse the necessary columns into attributes this class holds.

Parameters
start_time: float

Onset time of the note in seconds.

end_time: float

Offset time of the note in seconds.

note: int

Midi number of the number, should be within 21~108.

instrument: int

Instrument number in Midi.

velocity: int

Velocity of keypress, should be wihtin 0~127

start_beat: float

Start beat index of the note.

end_beat: float

End beat index of the note.

note_value: str

Type of the note (e.g. quater, eighth, sixteenth).

is_drum: bool

Whether the note represents the drum note.

Attributes
note
velocity

Dataset Loader

class omnizart.base.BaseDatasetLoader(feature_folder=None, feature_files=None, num_samples=100, slice_hop=1, feat_col_name='feature')

Base dataset loader for yielding training samples.

Parameters
feature_folder: Path

Path to the folder that contains the extracted feature files.

feature_files: list[Path]

List of paths to the feature files. One of feature_folder or feature_files must be specified.

num_samples: int

Total sample number to be yielded.

slice_hop: int

Hop size when initializing the start index.

feat_col_name: str

Name of the feature column stored in the .hdf feature files.

Yields
feature:

Input feature for training the model.

label:

Coressponding label representation.

Methods

get_dataset