vak.predict.frame_classification.predict_with_frame_classification_model#

vak.predict.frame_classification.predict_with_frame_classification_model(model_name: str, model_config: dict, dataset_path, checkpoint_path, labelmap_path, num_workers=2, transform_params: dict | None = None, dataset_params: dict | None = None, timebins_key='t', spect_scaler_path=None, device=None, annot_csv_filename=None, output_dir=None, min_segment_dur=None, majority_vote=False, save_net_outputs=False)[source]#

Make predictions on a dataset with a trained model.

model_namestr

Model name, must be one of vak.models.registry.MODEL_NAMES.

model_configdict

Model configuration in a dict, as loaded from a .toml file, and used by the model method from_config.

dataset_pathstr

Path to dataset, e.g., a csv file generated by running vak prep.

checkpoint_pathstr

path to directory with checkpoint files saved by Torch, to reload model

labelmap_pathstr

path to ā€˜labelmap.jsonā€™ file.

num_workersint

Number of processes to use for parallel loading of data. Argument to torch.DataLoader. Default is 2.

transform_params: dict, optional

Parameters for data transform. Passed as keyword arguments. Optional, default is None.

dataset_params: dict, optional

Parameters for dataset. Passed as keyword arguments. Optional, default is None.

spect_keystr

key for accessing spectrogram in files. Default is ā€˜sā€™.

timebins_keystr

key for accessing vector of time bins in files. Default is ā€˜tā€™.

devicestr

Device on which to work with model + data. Defaults to ā€˜cudaā€™ if torch.cuda.is_available is True.

spect_scaler_pathstr

path to a saved SpectScaler object used to normalize spectrograms. If spectrograms were normalized and this is not provided, will give incorrect results.

annot_csv_filenamestr

name of .csv file containing predicted annotations. Default is None, in which case the name of the dataset .csv is used, with ā€˜.annot.csvā€™ appended to it.

output_dirstr, Path

path to location where .csv containing predicted annotation should be saved. Defaults to current working directory.

min_segment_durfloat

minimum duration of segment, in seconds. If specified, then any segment with a duration less than min_segment_dur is removed from lbl_tb. Default is None, in which case no segments are removed.

majority_votebool

if True, transform segments containing multiple labels into segments with a single label by taking a ā€œmajority voteā€, i.e. assign all time bins in the segment the most frequently occurring label in the segment. This transform can only be applied if the labelmap contains an ā€˜unlabeledā€™ label, because unlabeled segments makes it possible to identify the labeled segments. Default is False.

save_net_outputsbool

if True, save ā€˜rawā€™ outputs of neural networks before they are converted to annotations. Default is False. Typically the output will be ā€œlogitsā€ to which a softmax transform might be applied. For each item in the datasetā€“each row in the dataset_path .csvā€“ the output will be saved in a separate file in output_dir, with the extension {MODEL_NAME}.output.npz. E.g., if the input is a spectrogram with spect_path filename gy6or6_032312_081416.npz, and the network is TweetyNet, then the net output file will be gy6or6_032312_081416.tweetynet.output.npz.