We can then deploy the model over longer sound files.

Below is an example of deploying a trained multi-class ResNet model over a longer sound file.

# Load the library
library(gibbonNetR)

# Load data
data("TempBinWav")

# Create a temp directory to save the file
dir.create(
  file.path(tempdir(), "/MultiDir/Wav/", sep = ""),
  recursive = T,
  showWarnings = FALSE
)

# Write to temp directory
writeWave(TempBinWav, filename = paste(file.path(tempdir(), "/MultiDir/Wav/"), "TempBinWav.wav", sep = ""))

# Find model path
trained_models_dir <- system.file("extdata", "trainedresnetmulti/", package = "gibbonNetR")

# Specify model path
ModelPath <- list.files(trained_models_dir, full.names = T)

# Deploy trained model over sound files
deploy_CNN_multi(
  clip_duration = 12,
  architecture = "resnet18",
  output_folder = file.path(tempdir(), "/MultiDir/Results/Images/", sep = ""),
  output_folder_selections = file.path(tempdir(), "/MultiDir/Results/Selections/", sep = ""),
  output_folder_wav = file.path(tempdir(), "/MultiDir/Results/Wavs/", sep = ""),
  detect_pattern = NA,
  top_model_path = ModelPath,
  path_to_files = paste(tempdir(), "/MultiDir/Wav/", sep = ""),
  downsample_rate = "NA",
  save_wav = F,
  class_names = c(
    "female.gibbon",
    "hornbill.helmeted",
    "hornbill.rhino",
    "long.argus",
    "noise"
  ),
  noise_category = "noise",
  single_class = FALSE,
  single_class_category = "female.gibbon",
  threshold = .25,
  max_freq_khz = 2
)

We can then look at the resulting selection table

# List the files in the selection table folder (as specified above)
TempDir <- list.files(file.path(tempdir(), "/MultiDir/Results/Selections/", sep = ""),
                      full.names = TRUE)

# Read in the selection table
read.delim(TempDir[1])

# There is one gibbon detection
Selection          View Channel Begin.Time..s. End.Time..s. Low.Freq..Hz.
1         1 Spectrogram 1       1             13           25           100
High.Freq..Hz. Probability        Detections         Class
1           2000        0.25 TempBinWav.wav_13 female.gibbon