Train a CNN

Convolutional neural networks (CNNs) are popular tools for creating automated machine learning classifiers on images or image-like samples. By converting audio into a two-dimensional frequency vs. time representation such as a spectrogram, we can generate image-like samples that can be used to train CNNs.

This tutorial demonstrates the basic use of OpenSoundscape’s preprocessors and cnn modules for training CNNs and making predictions using CNNs.

Under the hood, OpenSoundscape uses Pytorch for machine learning tasks. By using the class opensoundscape.ml.cnn.CNN, you can train and predict with PyTorch’s powerful CNN architectures in just a few lines of code.

Run this tutorial

This tutorial is more than a reference! It’s a Jupyter Notebook which you can run and modify on Google Colab or your own computer.

Link to tutorial

How to run tutorial

Open In Colab

The link opens the tutorial in Google Colab. Uncomment the “installation” line in the first cell to install OpenSoundscape.

Download via DownGit

The link downloads the tutorial file to your computer. Follow the Jupyter installation instructions, then open the tutorial file in Jupyter.

[22]:
# if this is a Google Colab notebook, install opensoundscape in the runtime environment
if 'google.colab' in str(get_ipython()):
  %pip install "opensoundscape==0.13.0" "jupyter-client<8,>=5.3.4" "ipykernel==6.17.1"
  num_workers=0
else:
  num_workers=4

Setup

Import needed packages

[23]:
# the cnn module provides classes for training/predicting with various types of CNNs
from opensoundscape import CNN

#other utilities and packages
import torch
import pandas as pd
from pathlib import Path
import numpy as np
import pandas as pd
import random
import subprocess
from glob import glob
import sklearn

#set up plotting
from matplotlib import pyplot as plt
plt.rcParams['figure.figsize']=[15,5] #for large visuals
%config InlineBackend.figure_format = 'retina'

Set random seeds

Set manual seeds for Pytorch and Python. These essentially “fix” the results of any stochastic steps in model training, ensuring that training results are reproducible. You probably don’t want to do this when you actually train your model, but it’s useful for debugging.

[24]:
torch.manual_seed(0)
random.seed(0)
np.random.seed(0)

Download files

Training a machine learning model requires some pre-labeled data. These data, in the form of audio recordings or spectrograms, are labeled with whether or not they contain the sound of the species of interest.

These data can be obtained from online databases such as Xeno-Canto.org, or by labeling one’s own ARU data using a program like Cornell’s Raven sound analysis software. In this example we are using a set of annotated avian soundscape recordings that were annotated using the software Raven Pro 1.6.4 (Bioacoustics Research Program 2022):

An annotated set of audio recordings of Eastern North American birds containing frequency, time, and species information. Lauren M. Chronister, Tessa A. Rhinehart, Aidan Place, Justin Kitzes. https://doi.org/10.1002/ecy.3329

These are the same data that are used by the annotation and preprocessing tutorials, so you can skip this step if you’ve already downloaded them there.

Download example files

Download a set of example audio files and Raven annotations:

Option 1: run the cell below

  • if you get a 403 error, DataDryad suspects you are a bot. Use Option 2.

Option 2:

[25]:
# Note: the "!" preceding each line below allows us to run bash commands in a Jupyter notebook
# If you are not running this code in a notebook, input these commands into your terminal instead
!wget -O annotation_Files.zip https://datadryad.org/stash/downloads/file_stream/641805;
!wget -O mp3_Files.zip https://datadryad.org/stash/downloads/file_stream/641807;
!mkdir annotated_data;
!unzip annotation_Files.zip -d ./annotated_data/annotation_Files;
!unzip mp3_Files.zip -d ./annotated_data/mp3_Files;
--2026-03-20 12:45:32--  https://datadryad.org/stash/downloads/file_stream/641805
Resolving datadryad.org (datadryad.org)... 54.200.119.136, 44.227.122.190, 54.213.102.118, ...
Connecting to datadryad.org (datadryad.org)|54.200.119.136|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://datadryad.org/downloads/file_stream/641805 [following]
--2026-03-20 12:45:33--  https://datadryad.org/downloads/file_stream/641805
Reusing existing connection to datadryad.org:443.
HTTP request sent, awaiting response... 403 Forbidden
2026-03-20 12:45:33 ERROR 403: Forbidden.

--2026-03-20 12:45:33--  https://datadryad.org/stash/downloads/file_stream/641807
Resolving datadryad.org (datadryad.org)... 44.227.122.190, 54.213.102.118, 54.200.191.246, ...
Connecting to datadryad.org (datadryad.org)|44.227.122.190|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://datadryad.org/downloads/file_stream/641807 [following]
--2026-03-20 12:45:33--  https://datadryad.org/downloads/file_stream/641807
Reusing existing connection to datadryad.org:443.
HTTP request sent, awaiting response... 403 Forbidden
2026-03-20 12:45:33 ERROR 403: Forbidden.

mkdir: annotated_data: File exists
Archive:  annotation_Files.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of annotation_Files.zip or
        annotation_Files.zip.zip, and cannot find annotation_Files.zip.ZIP, period.
Archive:  mp3_Files.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of mp3_Files.zip or
        mp3_Files.zip.zip, and cannot find mp3_Files.zip.ZIP, period.

Prepare audio data

To prepare audio data for machine learning, we need to convert our annotated data into clip-level labels.

These steps are covered in depth in other tutorials, so we’ll just set our clip labels up quickly for this example.

First, get exactly matched lists of audio files and their corresponding selection files:

[26]:
# Set the current directory to where the dataset is downloaded
dataset_path = Path("./annotated_data/")

# Make a list of all of the selection table files
selection_files = glob(f"{dataset_path}/annotation_Files/*/*.txt")

# Create a list of audio files, one corresponding to each Raven file
# (Audio files have the same names as selection files with a different extension)
audio_files = [
    f.replace("annotation_Files", "mp3_Files").replace(
        ".Table.1.selections.txt", ".mp3"
    )
    for f in selection_files
]

Next, convert the selection files and audio files to a BoxedAnnotations object, which contains the time, frequency, and label information for all annotations for every recording in the dataset.

[27]:
from opensoundscape.annotations import BoxedAnnotations

# Create a dataframe of annotations
annotations = BoxedAnnotations.from_raven_files(
    raven_files=selection_files, audio_files=audio_files, annotation_column="Species"
)
/Users/SML161/opensoundscape/opensoundscape/annotations.py:347: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
  all_annotations_df = pd.concat(all_file_dfs).reset_index(drop=True)
[28]:
%%capture
# Parameters to use for label creation
clip_duration = 3
clip_overlap = 0
min_label_overlap = 0.25
species_of_interest = ["NOCA", "EATO", "SCTA", "BAWW", "BCCH", "AMCR", "NOFL"]

# Create dataframe of one-hot labels
clip_labels = annotations.clip_labels(
    clip_duration = clip_duration,
    clip_overlap = clip_overlap,
    min_label_overlap = min_label_overlap,
    class_subset = species_of_interest # You can comment this line out if you want to include all species.
)
[29]:
clip_labels.head()
[29]:
NOCA EATO SCTA BAWW BCCH AMCR NOFL
file start_time end_time
annotated_data/mp3_Files/Recording_1/Recording_1_Segment_31.mp3 0.0 3.0 False True False False False False False
3.0 6.0 False False False False False False False
6.0 9.0 False True False False False False False
9.0 12.0 False False False False False False False
12.0 15.0 False False False False False True False

Visualize labeled samples as a sanity check

You can run this cell multiple time to get randomly selected clips from each category. It’s super important to check that your labels look good before training or evaluating a classifier on them!

Wow - those are some busy soundscapes.

[30]:
from opensoundscape.visualization import inspect

print(f"clips with Northern Cardinal (NOCA) labels:")
widget = inspect(
    clip_labels[clip_labels["NOCA"] == True], N=4, bandpass_range=(0, 8000)
)

print(f"clips with Northern Flicker (NOFL) labels:")
widget = inspect(
    clip_labels[clip_labels["NOFL"] == True], N=4, bandpass_range=(0, 8000)
)

print(f"clips with none of the selected species ({species_of_interest}) labeled:")
widget = inspect(clip_labels[clip_labels.sum(1) == 0], N=4, bandpass_range=(0, 8000))
clips with Northern Cardinal (NOCA) labels:
clips with Northern Flicker (NOFL) labels:
clips with none of the selected species (['NOCA', 'EATO', 'SCTA', 'BAWW', 'BCCH', 'AMCR', 'NOFL']) labeled:

Create train, validation, and test datasets

To train and test a model, we use three datasets:

  • The training dataset is used to fit your machine learning model to the audio data.

  • The validation dataset is a held-out dataset that is used to select hyperparameters (e.g. how many steps to train for) during training

  • The test dataset is another held-out dataset that we use to check how the model performs on data that were not available at all during training.

While both the training and validation datasets are used while training the model, the test dataset is never touched until the model is fully trained and completed.

The training and validation datasets may be gathered from the same source as each other. In contrast, the test dataset is often gathered from a different source to assess whether the model’s performance generalizes to a real-world problem. For example, training and validation data might be drawn from an online database like Xeno-Canto, whereas the testing data is from your own field data.

Create a test dataset

We’ll separate the test dataset first. For a good assessment of the model’s generalization, we want the test set to be independent of the training and validation datasets. For example, we don’t want to use clips from the same source recording in the training dataset and the test dataset.

For this example, we’ll use the recordings in the folders Recording_1, Recording_2 and Recording_3 as our training and validation data, and use the recordings in folder Recording_4 as our test data.

[31]:
# Select all files from Recording_4 as a test set
mask = clip_labels.reset_index()["file"].apply(lambda x: "Recording_4" in x).values
test_set = clip_labels[mask]

# All other files will be used as a training set
train_and_val_set = clip_labels.drop(test_set.index)

# Save .csv tables of the training and validation sets to keep a record of them
train_and_val_set.to_csv("./annotated_data/train_and_val_set.csv")
test_set.to_csv("./annotated_data/test_set.csv")

If you wanted, you could load the training and testing set from these saved CSV files.

[32]:
train_and_val_set = pd.read_csv(
    "./annotated_data/train_and_val_set.csv", index_col=[0, 1, 2]
)
test_set = pd.read_csv("./annotated_data/test_set.csv", index_col=[0, 1, 2])

Split training and validation datasets

Now, separate the remaining non-test data into training and validation datasets.

The idea of keeping a separate validation dataset is that, throughout training, we can ‘peek’ at the performance on the validation set to choose hyperparameters. (This is in contrast to the test dataset, which we will not look at until we’ve finished training our model.)

One important hyperparameter is the number of steps to train for, in order to prevent overfitting. Each batch constitutes one training step.

If a model’s performance on a training dataset continues to improve as it trains, but its performance on the validation dataset plateaus or decreases, this could incate the model is overfitting on the training dataset, learning information specific to those particular samples instead of gaining the ability to generalize to new data.

In that case, we want to revert back to the version of the model with the best validation set performance.

[33]:
# Split our training data into training and validation sets
train_df, valid_df = sklearn.model_selection.train_test_split(
    train_and_val_set, test_size=0.1, random_state=0
)
[34]:
train_df.to_csv("./annotated_data/train_set.csv")
valid_df.to_csv("./annotated_data/valid_set.csv")

Resample data for even class representation

Before training, we will balance the number of samples of each class in the training set. This helps the model learn all of the classes, rather than paying too much attention to the classes with the most labeled annotations.

[35]:
from opensoundscape.data_selection import resample

# upsample (repeat samples) so that all classes have 800 samples
balanced_train_df = resample(train_df, n_samples_per_class=800, random_state=0)

Set up model

Now we create a model object. We have to select several parameters when creating this object: its architecture, classes, and sample_duration.

Some additional parameters can also be changed at this step, such as the preprocessor used to create spectrograms and the shape of the spectrograms.

For more detail on this step, see the “Customize CNN training” tutorial.

Create CNN object

Now, create a CNN object with this architecture, the classes we put into the dataframe above, and the same sample duration as we selected above.

The first time you run this script for a particular architecture, OpenSoundscape will download the desired architecture.

[ ]:
# Create a CNN object designed to recognize 3-second samples
from opensoundscape import CNN

# Use resnet34 architecture
architecture = "resnet34"

# Can use this code to get your classes, if needed
class_list = list(train_df.columns)

model = CNN(
    architecture=architecture,
    classes=class_list,
    sample_duration=clip_duration,  # 3s, selected above
    sample_rate=32000,
)

Check model device

If a GPU is available on your computer, the CNN object automatically selects it for accellerating performance. You can override .device to use a specific device such as cpu or cuda:3

[37]:
print(f"model.device is: {model.device}")
model.device is: mps

Set up WandB model logging

While this step is optional, it is very helpful for model training. In this step, we set up model logging on a service called Weights & Biases (AKA WandB).

Weights & Biases is a free website you can use to monitor model training. It is integrated with OpenSoundscape to include helpful functions such as checking on your model’s training progress in real time, visualizing the spectrograms created for training your model, comparing multiple tries at training the same model, and more. For more information, check out this blog post.

The instructions below will help you set up wandb logging:

  • Create an account on the Weights and Biases website.

  • The first time you use wandb, you’ll need to run wandb.login() in Python or wandb login on the command line, then enter the API key from your settings page

  • In a Python script where you want to log model training, use wandb.init() as demonstrated below. The “Entity” or team option allows runs and projects to be shared across members in a group, making it easy to collaborate and see progress of other team members’ runs.

As training progresses, performance metrics will be plotted to the wandb logging platform and visible on this run’s web page. For example, this wandb web page shows the content logged to wandb when this notebook was run by the Kitzes Lab. By default, OpenSoundscape + WandB integration creates several pages with information about the model:

  • Overview: hyperparameters, run description, and hardware available during the run

  • Charts: “Samples” panel with audio and images of preprocessed samples (useful for checking that your preprocessing performs as expected and your labels are correct)

  • Charts: graphs of each class’s performance metrics over training time

  • Model: summary of model architecture

  • Logs: standard output of training script

  • System: computational performance metrics including memory, CPU use, etc

When training several models and comparing performance, the “Project” page of WandB provides comparisons of metrics and hyperparameters across training runs.

[38]:
import wandb

try:
    wandb.login()
    wandb_session = wandb.init(
        entity="kitzeslab",  # replace with your entity/group name
        project="OpenSoundscape tutorials",
        name="Train CNN",
    )
except:  # if wandb.init fails, don't use wandb logging
    print("failed to create wandb session. wandb session will be None")
    wandb_session = None
wandb: Currently logged in as: samlapp (deepbirddetect) to https://api.wandb.ai. Use `wandb login --relogin` to force relogin
creating run (0.6s)
Tracking run with wandb version 0.21.0
Run data is saved locally in /Users/SML161/opensoundscape/docs/tutorials/wandb/run-20260320_124550-qlbb9o4q
Syncing run Train CNN to Weights & Biases (docs)

Train the CNN

Finally, train the CNN for two epoch. Typically, we would train the model for more than 30 steps, but because training is slow and is much better done outside of a Jupyter Notebook, we just include this as a short demonstration of training.

Training proceeds in steps, with each step showing the model a batch containing a bunch of samples (usually at least 64). The machine learning model predicts on every sample in the batch, then the model weights are updated based on those samples. Larger batches can increase training speed, but require more memory. If you get a memory error, try reducing the batch size.

We use default training parameters, but many aspects of CNN training can be customized (see the “Customize CNN training” tutorial for examples).

[39]:
checkpoint_folder = Path("model_training_checkpoints")
checkpoint_folder.mkdir(exist_ok=True)

# Note: if you don't want to compute and log metrics for each individual class, set
# model.compute_per_class_metrics = False
[ ]:
# %%capture --no-stdout --no-display
# Uncomment the line above to silence outputs from this cell

model.train(
    balanced_train_df,
    valid_df,
    steps=30,
    batch_size=64,
    log_interval=100,  # log progress every 100 batches
    num_workers=num_workers,  # parallelized cpu tasks for preprocessing
    wandb_session=wandb_session,
    save_path=checkpoint_folder,  # location to save checkpoints
)
wandb: WARNING Data passed to `wandb.Image` should consist of values in the range [0, 255], image data will be normalized to this range, but behavior will be removed in a future version of wandb.

Training Epoch 0
Epoch: 0 [batch 0/109, 0.00%]
        Epoch Running Average Loss: 0.728
        Most Recent Batch Loss: 0.728
Epoch: 0 [batch 100/109, 91.74%]
        Epoch Running Average Loss: 0.446
        Most Recent Batch Loss: 0.400

Validation.

Training Epoch 1
Epoch: 1 [batch 0/109, 0.00%]
        Epoch Running Average Loss: 0.313
        Most Recent Batch Loss: 0.313
Epoch: 1 [batch 100/109, 91.74%]
        Epoch Running Average Loss: 0.296
        Most Recent Batch Loss: 0.256

Validation.

Best Model Appears at Epoch 1 with Validation score 0.910.

Once this is finished running, you have trained the CNN.

To generate predictions on audio files using the CNN, use the .predict() method of the CNN object. Here, we apply a sigmoid activation layer which maps the CNN’s outputs (all real numbers) to a 0-1 range.

[41]:
scores_df = model.predict(valid_df.head(), activation_layer="sigmoid")
scores_df.head()
[41]:
NOCA EATO SCTA BAWW BCCH AMCR NOFL
file start_time end_time
annotated_data/mp3_Files/Recording_1/Recording_1_Segment_11.mp3 75.0 78.0 0.045070 0.400547 0.001133 0.157310 0.027055 0.200161 0.033820
annotated_data/mp3_Files/Recording_1/Recording_1_Segment_04.mp3 12.0 15.0 0.032290 0.556500 0.000280 0.006704 0.013564 0.000709 0.004292
annotated_data/mp3_Files/Recording_2/Recording_2_Segment_01.mp3 60.0 63.0 0.006733 0.075441 0.047699 0.021585 0.100145 0.007114 0.005321
annotated_data/mp3_Files/Recording_1/Recording_1_Segment_05.mp3 9.0 12.0 0.101767 0.144876 0.015483 0.013932 0.113902 0.182582 0.005553
annotated_data/mp3_Files/Recording_1/Recording_1_Segment_14.mp3 9.0 12.0 0.212231 0.157232 0.001565 0.032767 0.314256 0.001502 0.003562

Saving and exporting the model

There are a few different ways we can save the trained model depending on downstream use cases. In general, you can simply use the model.save(path) function to save the model in a JSON format that can be reloaded by OpenSoundscape (opso.load_model(path) or CNN.load(path)). To load the raw dictionary of saved content, use torch.load(path,weights_only=False).

When you want to continue training from a saved model file, it is helpful to use model.save(pickle=True) which saves a compressed version of the entire Python object, rather than a JSON-like format. Unlike the default saving method, this saved object retains temporary model training states like the optimizer and learning rate scheduler states. However, note that when you saved a pickled model object, you could encounter issues re-loading it in different Python environments or different versions of OpenSoundscape. After saving a pickled model, you can reload it in the same way as normal: opso.load_model(path) or CNN.load(path).

ONNX Export

ONNX (Open Neural Network Exchange) is a cross-platform format for representing neural networks on a wide range of hardware and operating systems. Exporting a model to ONNX is useful for edge computing and other inference-only applications where you want independence from PyTorch. Note that not all models can be exported to ONNX. In particular, the supported method for creating a model that can be exported to ONNX is to initialize the model with the TorchSpectrogramPreprocessor class as the preprocessor. This preprocessor is designed for compatability with PyTorch’s torch.onnx.export function. Here’s an example:

[3]:
from opensoundscape import CNN, preprocessors

model = CNN(
    architecture="efficientnet_b0",
    classes=[0, 1, 2, 3],
    sample_duration=3,
    preprocessor_cls=preprocessors.TorchSpectrogramPreprocessor,
    sample_rate=32000,
)
onnx_program = model.save_onnx("./opso_efficientnet.onnx", activation_layer="sigmoid")
/Users/SML161/miniconda3/envs/opso_dev/lib/python3.13/site-packages/onnxscript/converter.py:457: DeprecationWarning: Expression.__init__ got an unexpected keyword argument 'lineno'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
  expr = ast.Expression(expr, lineno=expr.lineno, col_offset=expr.col_offset)
/Users/SML161/miniconda3/envs/opso_dev/lib/python3.13/site-packages/onnxscript/converter.py:457: DeprecationWarning: Expression.__init__ got an unexpected keyword argument 'col_offset'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
  expr = ast.Expression(expr, lineno=expr.lineno, col_offset=expr.col_offset)
[torch.onnx] Obtain model graph for `ONNXModel()` with `torch.export.export(..., strict=False)`...
[torch.onnx] Obtain model graph for `ONNXModel()` with `torch.export.export(..., strict=False)`... ✅
[torch.onnx] Run decomposition...
[torch.onnx] Run decomposition... ✅
[torch.onnx] Translate the graph into ONNX...
[torch.onnx] Translate the graph into ONNX... ✅
/Users/SML161/miniconda3/envs/opso_dev/lib/python3.13/site-packages/onnx/reference/ops/op_range.py:13: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
  return (np.arange(starts, ends, steps).astype(starts.dtype),)
Applied 9 of general pattern rewrite rules.

This saves an ONNX program for inference (prediction). The program produces three outputs by default: the pre-processed audio sample (a spectrogram), the embedding layer outputs, and the final classifier outputs. You can turn off any of these outputs using the arguments to .save_onnx(). If model.network.classifier_layer is not set, the function will not know which layer to use for embeddings, and will instead create a program that only exports the pre-processed sample and the final classifier outputs.

You can also directly use the lower-level functions opso.export.to_onnx_program to export custom model classes, or inspect the code in that function to build a custom onnx export method.

The ONNX program can be run in various ways once it is exported. In Python, you can run onnx programs using the onnx_runtime package. Here’s a sample script:

import onnx, onnxruntime
import numpy as np

combined_model = onnx.load("opso_efficientnet.onnx")
output_names = [node.name for node in combined_model.graph.output]

onnx.checker.check_model(combined_model)


EP_list = ["CPUExecutionProvider"]  # ["CUDAExecutionProvider", "CPUExecutionProvider"]
ort_session = onnxruntime.InferenceSession("opso_efficientnet.onnx", providers=EP_list)

# make up some random inputs
audio_samples_per_input = (
    combined_model.graph.input[0].type.tensor_type.shape.dim[2].dim_value
)
batch_size = 3
input_batched = np.random.rand(batch_size, 1, audio_samples_per_input).astype(
    np.float32
)

# compute ONNX Runtime output prediction
ort_inputs = {ort_session.get_inputs()[0].name: input_batched}
ort_outs = ort_session.run(None, ort_inputs)

# restore the name-value dictionary mapping of outputs
outs_dict = {name: ort_outs[i] for i, name in enumerate(output_names)}
print(f"shape of outputs for inference on one batch of batch size {batch_size}:")
print({k: v.shape for k, v in outs_dict.items()})

We don’t expect this CNN to actually be good at classifying sounds, since we only trained it with a few examples and for a few steps. We’d want to train with hundreds of examples per class for 1,000 steps as a starting point for training a useful model.

For guidance on how to use machine learning classifiers, see the Classifieres 101 Guide on opensoundscape.org and the tutorial on predicting with pre-trained CNNs.

For transfer learning from pre-trained CNNs, see the transfer learning tutorial notebook.

Clean up: Run the following cell to delete the files created in this tutorial.

[ ]:
import shutil
from pathlib import Path

# uncomment to remove the training files
# shutil.rmtree('./annotated_data')

if Path("./wandb").exists():
    shutil.rmtree("./wandb")
if Path("./model_training_checkpoints").exists():
    shutil.rmtree("./model_training_checkpoints")
try:
    Path("opso_efficientnet.onnx").unlink()
except:
    pass
try:
    Path("annotation_Files.zip").unlink()
except:
    pass
try:
    Path("mp3_Files.zip").unlink()
except:
    pass