bacpipe.core.experiment_manager
Functions
|
|
Classes
|
Initiate the generation of embedding by creating a Loader object. |
|
PurePath subclass that can make system calls. |
|
Decorate an iterable object, returning an iterator which acts exactly like the original iterable, but prints a dynamically updating progressbar every time a value is requested. |
- class bacpipe.core.experiment_manager.Loader(audio_dir, model_name=None, check_if_combination_exists=True, dim_reduction_model=False, use_folder_structure=False, testing=False, **kwargs)[source]
Bases:
objectInitiate the generation of embedding by creating a Loader object. This object will handles paths for loading and saving data. During this process it collects metadata which can be accessed as an attribute and will be saved after the successful run. kwargs that are not specifically passed will be taken from bacpipe.config and bacpipe.settings.
- __init__(audio_dir, model_name=None, check_if_combination_exists=True, dim_reduction_model=False, use_folder_structure=False, testing=False, **kwargs)[source]
Initiate the generation of embedding by creating a Loader object. This object will handles paths for loading and saving data. During this process it collects metadata which can be accessed as an attribute and will be saved after the successful run. kwargs that are not specifically passed will be taken from bacpipe.config and bacpipe.settings.
- Parameters:
audio_dir (string or pathlib.Path) – path to audio data
model_name (string, optional) – Name of the model that should be used, by default None
check_if_combination_exists (bool, optional) – If false new embeddings are created and the checking is skipped, by default True
dim_reduction_model (bool, optional) – Either false if primary embeddings are created or the name of the dimensionaliry reduction model if dim reduction should be performed, by default False
use_folder_structure (bool, optional) – If True data will be saved and the output folder structure will be created, by default False
testing (bool, optional) – Testing yes or no?, by default False
- embeddings(return_type='dict')[source]
Load and return processed embeddings. This method can only be used to return already computed embeddings. Embeddings can be returned as np.array (array) or as dictionary (dict) in which case the keys will correspond to the corresponding embedding file name. In case of the array, all embeddings are concatenated so that the first dimension corresponds to the timestamp and the second dimension to the embedding dimension.
- Parameters:
return_type (str, optional) – return type either array or dict, by default ‘dict’
- Returns:
depending on return_type argument
- Return type:
array or dict
- static get_audio_files(audio_dir, audio_suffixes=['.wav', '.WAV', '.aif', '.mp3', '.MP3', '.flac', '.ogg'], return_type='pathlib.Path')[source]
Collect all audio files in a given directory that have file endings that can be processed by bacpipe.
- Parameters:
audio_dir (str) – path to audio data
audio_suffixes (list, optional) – list of audio suffixes, by default settings.audio_suffixes
return_type (str, optional) – specify if list should be returned as list of strings or list of pathlib.Path objects which comes in handy for some downstream processing, by default ‘pathlib.Path’
- Returns:
list of audio files
- Return type:
list
- predictions(return_type='dict')[source]
Load and return classifier predictions. This method can only be used for already processed predictions. Predictions that have been processed will be returned based on the specified return_type: array for np.array, in which case all predictions are concatenated and a dictionary is passed referencing the index to the corresponding label. dict for a dictionary, in which case the keys correspond to the audio file name corresponding to the annotation and the values are np.arrays with all annotations of that file dataframe for a dataframe with columns for each species that was active and columns for filename, start and end times.
- Parameters:
return_type (str, optional) – return either array, dict or dataframe, by default ‘dict’
- Returns:
either tuples of (np.array, dict) for array or tuple of (dict, dict) for dict or pd.DataFrame
- Return type:
tuple or pd.DataFrame