Object Detection with ModelArts
Hello everyone! In this article, I will try to explain how to use Huawei Cloud ModelArts Service for Object Detection and make a demonstration about it. Let’s hop on to it.
Introduction
Object Detection is a AI modeling type that you can use for detecting objects in an image or video. Most of the Object detection models using CNN algorithms for training the model. Huawei Cloud provides automatic ExeML training algortihm for Object Detection models. Today we are going to use that algorithm to train our model. Let’s hop on to it!
Object Detection with ModelArts Demonstration
At the below there is the lifecycle of a AI Development lifecycle. We are going to follow that cycle. First we are going to find or create a dataset for ourselves. After that we are going to prepare the data for training. Like cutting the nonsense datas from dataset. After we will start the training from Object Detection ExeML service on ModelArts. If we have a good training results and metrics we can deploy and try that model for our purposes.
First we need a dataset to teach our model how to predict. So we can use some websites like Kaggle.com. If you want a unique dataset, you can create your own dataset of course. But for this example we are going to use a public dataset of game cards from kaggle.com. This is the dataset we are going to use it for our Object detection model. There is about 600 card images we can use. With these datas, model is going to predict which card we have in our hands.
After we download the dataset from kaggle.com, we just unzip it and check the images we are going to use for training.
For using these images for our model training, we need to upload them to OBS system on Huawei Cloud. OBS is a cloud block storage service which Huawei Cloud provides. There are three ways we can upload our dataset to OBS system. obsutil, ObsBrowser+ and Huawei cloud console. Huawei Cloud console is not a great way to upload large folders to OBS system so we are going to create our OBS Bucket from console then we will upload our dataset with obsutil and ObsBrowser+ application. First let’s see how we can create our bucket with OBS Console.
Creating bucket with OBS Console.
Now we have our bucket to upload our dataset. Let’s upload it!
Uploading dataset with ObsBrowser+
For downloading ObsBrowser+, you can use this link.
After you log in to your Huawei Cloud account with ObsBrowser+. We can upload our dataset to our bucket for using it in ModelArts service.
Uploading dataset with obsutil
For downloading obsutil you can follow this article.
After downloading obsutil to your work environment, we can upload our dataset with these CLI commands.
obsutil cp [dataset path] [obs bucket path] -r -f
obsutil cp archive obs://bucket-dtt-training -r -f
We can see our dataset on our huawei cloud console, ObsBrowser+ or obsutil with
obsutil ls -a obs://bucket-dtt-training
command.
After we upload our dataset to bucket we create two folders besides to the dataset folder. One for output and one for empty input. We will use these empty folders for creating dataset on ModelArts service.
After we completed all of this, we can hop on to ModelArts service to create our ExeML project.
We click to the Service list from the home page of Huawei Cloud console and write ModelArts to search bar. Click the related link for ModelArts service. Then we click to the ExeML section and find the Object Detection model training part. Click to Create Project
We name our ExeML project and starting to create a dataset. We didnt upload our images to ModelArts service thats why we need to create a new dataset for our Model training. We name our dataset and giving the paths of empty input for input section and output for output section.
When the ExeML project is created, our dataset is created with it. So we come back to the ModelArts console and click Data Management > Datasets.
Then we find the labeling job section and click the labeling job created automaticly.
As you know, we use a empty input folder when we were creating a dataset for ModelArts service. So we need to upload our real dataset to the system. So we click Add data > Add Data
In the opening window we select these configurations and select the folder(dataset) we uploaded from our local pc.
As you can see, we have 536 labeled images and one unlabeled image. So we label that unlabeled image ourselves.
Then we realise there is a miss spelling label in the dataset. Seven of seven. We remove that label and label the image which has been unlabeled after we remove the unnecessary label tag.
Now, we are ready to train our model. Come back to ModelArts console and go to ExeML section. Find our project and click it.
We can see our dataset in here either. If we are ready to train the model we can click Train button at top right corner.
We can choose a version name and training, validation set ratio. Training ratio is the ratio that ModelArts going to use the amount of image for training. Same for validation. We select none for incremental version because this is the first time we train this dataset. If we want to train this model incremently we can select the version we want to write on. Select the other configurations and start the training by clicking next.
We wait until the training process is over.
When the process is over we can see the metrics of our model.
ModelArts supports every stage of an AI development. So we can deploy our model and try it. Click deploy top left corner and select your spesifications. Select auto stop after 1 hour so you don’t forget and charged more than you want to.
After deployment is over, we can try our model with the instructions below.
Final thoughts and Summary
As you can see our model works even though we only train around 10 images for each class we have. If you try some other test values you can see that the model doesn’t work perfect and this is very normal. We only find out a dataset from kaggle.com and try to create an Object Detection model with it. It can be improved by many other ways. That is a new article topic i guess.