☁ ModelArts ExeML Sound Classification with Cat and Dog dataset

Muhammet Berke OZTURK
Huawei Developers
Published in
7 min readOct 24, 2023
Cover photo

In this article, I will try to explain how to use Huawei Cloud ModelArts Service for Sound Classification and make a demonstration with the Cat and Dog dataset from Kaggle. Let’s hop on to it.

Introduction

Sound Classification with ModelArts is an AI modeling service for Huawei Cloud that you can use to predict the classifications of a given audio data to the model.

For example, you can use it for predicting audios belonging to which bird species. First of all, you need a dataset of images that you want to predict. ModelArts suggests you have at least 100 audio for each class that you want to train. In this article, we are going to use a dataset from Kaggle which contains 85 dog and 125 cat audio files to train our model.

What is Kaggle? It is an online community of data scientists and machine learning engineers. Kaggle allows users to find datasets they want to use in building AI models, publish datasets, work with other data scientists and machine learning engineers, and enter competitions to solve data science challenges.

We have our dataset and we have our end-to-end AI Development platform ModelArts, so what are we waiting for? Let’s hop on to it!

Sound Classification

Data Preparation

Like We said before, first we need a dataset and we don’t want to collect all the images by ourselves. So we hop into Kaggle and find a suitable database.

Data collecting from Kaggle(1)

Write to the search bar Cat-Dog Audio Dataset and click the first one below.

Data collecting from Kaggle(2)

Download the dataset by clicking the Download button at the top right corner.

Data collecting from Kaggle(3)

After downloading the dataset as a zip file, decompress it. Now we should upload our dataset to OBS to use these sound data to train our model.

Uploading Data to OBS

We are going to use obsutil solution for this task. If you don't know how to upload data to OBS with obsutil click the link for instructions.

If you don’t have a bucket in your Huawei Cloud OBS system, follow the instructions below and create one.

Log into your Huawei Cloud account and Click Object Storage Service from the Service List.

Uploading Data to OBS(1)

Click on Create Bucket from the top right corner of OBS Console.

Uploading Data to OBS(2)

Create your bucket with the configurations below.

Uploading Data to OBS(3)

Now we created our bucket. We can create a folder for our dataset and upload our audio files through obsutil.

Uploading Data to OBS(4)

Creating folders with the instructions below.

Uploading Data to OBS(5)
Uploading Data to OBS(6)
Uploading Data to OBS(7)

Use obsutil to upload your dataset to OBS with the instructions and CLI commands below.

Uploading Data to OBS(8)
obsutil cp [**YOUR TRAIN DATASET DIRECTORY**] obs://[**YOUR BUCKET NAME**] -r -f
Uploading Data to OBS(9)

As you can see from the OBS Console and CLI response, we successfully uploaded our data to the OBS service.

Uploading Data to OBS(10)

We created 2 new folders for the ModelArts ExeML service. One for input and one for output.

Uploading Data to OBS(11)
Uploading Data to OBS(12)
Uploading Data to OBS(13)
Uploading Data to OBS(14)

We are done with uploading our dataset to OBS. So we can hop on to ModelArts service and integrate our OBS data to ModelArts service to train our model.

ModelArts integration with OBS and Model Training

Come back to the Service List and find ModelArts service.

Model Training(1)

Select ExeML from left navigation bar and Create a Sound Classification project.

Model Training(2)

Give your exeML project and dataset a name and select the input and output paths from the OBS service.

Model Training(3)
Model Training(4)
Model Training(5)
Model Training(6)

Click Create Now after that.

Model Training(7)

After the exeML project is created, go back to the ModelArts console and hop on to the Dataset section from Data Management. Find your dataset and click its name.

Model Training(8)
Model Training(9)

On the opening page, click the default labeling job.

Model Training(10)

Click Add Data dropdown box and Add data again.

Model Training(11)

Set the configurations below and insert your OBS path which contains the real training data.

Model Training(12)
Model Training(13)

Now our OBS data is integrated with the ModelArts dataset and we can see our data on both Dataset and ExeML sections.

Model Training(14)

Go back to the ModelArts console ExeML section and click your ExeML project.

Model Training(15)

As you can see we have our data here too. If everything is fine from here, click the train button from the top right corner and start the model training.

Model Training(16)
Model Training(17)

Model Deployment

After a while, the training is over, we can see the metrics of our training and model. Now we are ready to deploy our model to test. Click the Deploy button like below.

Model Deployment(1)
Model Deployment(2)

After one or two minutes deployment has been completed. We can either test our model through the ModelArts console like I am going to do it right now or use API at the below right corner.

Model Testing

Let’s upload our test data and test it.

Model Testing(1)
Model Testing(2)
Model Testing(3)

Our model works just fine for the effort we give! You can try different test datas on the model.

Conclusion

In this article, we trained a Sound classification model with Huawei Cloud ModelArts service. We used a public dataset of Cat-Dog Audio datas from Kaggle and trained it to classificate these two animals by their voices.

As you can see you can easily create Sound classification models with Huawei Cloud ModelArts service and deploy it. You can combine this service with other services to make more complex projects. ModelArts allows you to use this deployed model with API Reference.

References

--

--