【ModelArts Course4】Using Built-in Algorithm for Food Detection

举报
杜甫盖房子 发表于 2023/03/14 11:37:37 2023/03/14
【摘要】 ModelArts - Using Built-in Algorithm for Food Detection IntroductionModelArts is a one-stop AI development platform that supports the entire development process, including data processing, algorit...

ModelArts - Using Built-in Algorithm for Food Detection

Introduction

ModelArts is a one-stop AI development platform that supports the entire development process, including data processing, algorithm development and model training, management, and deployment.

This document describes how to upload local images to ModelArts and use built-in algorithm on ModelArts to train an object detection model.

Preparations

Before using ModelArts, you should complete these preparations:

Data Labeling

Model training requires a large amount of labeled data. Therefore, before training a model, label data.

Download Dataset

We have provided a dishes detect dataset which is part labeled, and you should use ModelArts to label the rest of unlabeled images.

Click this link to download and decompress it. After you decompressed it, you will see a directory organized as below:

├─dishes_detect_600
│  ├─test
│      └─dishes_*.png, 100 images for test
│  └─train
│      ├─dishes_*.png, 510 images for train, 500 labeled, 10 unlabeled

Upload Dataset

Open the OBS Browser+, go into a bucket, select a path, click Upload -> Folder -> Select dishes_detect_600 directory on your computer -> click OK, then the uploading task will begin, you can click Task Management for more details. You should waiting for the task to complete.

Import dataset from OBS to ModelArts

Click this link back to ModelArts console, click “Create”, as show in below.

Modify the dataset name as “dataset-dishes-detect”, then manual create an OBS path as the Output Dataset Path

Click Next, Labeling Status choose “Labeled”, then click the Import Path

select the dishes_detect_600/train directory as the Import Path

Click Submit, the import status is “Running”, wait for about 1 minute the import status will turn into “Completed”

Manual Labeling

Click the “dataset-dishes-detect”, click “View Details” to view data annotation.

As you can see, 10 images are unlabeled and 500 images are labeled. Click Back to Dataset Dashboard -> Labeling Job -> Create.

Modify the Labeling Type as Object detection, click Create

Click the task name,

Click Unlabeled, click the first image

Left-click and drag the mouse to draw a bounding box to cover each dish. Click Next to label next image. You can finish labeling the rest of images or just click Back to Data Labeling Preview.

Publish a New Verison

After finish labeling images, click Back to Data Labeling Preview -> Back to Data Labeling List -> Datasets -> New Version,

Click dataset-dishes-detect -> Versions -> Release New Version (on the top right), input 0.9 as the Training Set Ratio, choose Object detection as the Labeling Type,

Click Yes, Waiting for the status become “Normal”.

Now, you have finish the data labeling task.

Algorithm Development

After a labeled dataset is prepared, then you should prepare an AI algorithm. An AI algorithm will define a deep learning network and corresponding image preprocessing strategy, image augmentation strategy and training strategy. Only on the premise of having an algorithm can you use labeled dataset to train the network.

This section describes how to use built-in algorithm on ModelArts to train an object detection model. Built-in algorithm is an algorithm that published by ModelArts officially and can be used to create training job conveniently.

Click this link back to ModelArts Console, then click AI Gallery

You will see an algorithm named Object Detection-YOLOv5, click it

Click Subscribe (if it is display “Subscribed”, just skip it), then click Access Console, select AP-Singapore Region

Model Training

On ModelArts, we need create a training job to train a model.Follow previous step, click “Create training job”

Click Dataset, choose dataset-dishes-detect(V001) which is published before. Click Data path, create a new OBS directory named dishes_detect_training_output and choose it

Modify Hyperparameters, such as model_name = l, batch-size = 48, epochs = 50, the other parameters keep default.

The Instance Flavor choose 1*NVIDIA-V100

Click Submit,the training job will run,

Click job name, you can view training job details such as created time, duration and training log,

After about 14 minutes, the job’s status will change to “Completed”.

Model Management

When the training job is completed, we can click Evaluation Results to view Prediction Results and Mean Average Precision (mAP), the higher mAP means the model is better.

We can also click Create AI Application button on the top right, to import the trained model as an application.

Just click Create Now, you don’t need modify anything, ModelArts will import the model trained by the training job and package it as a docker mirror.

It will cost about 8 minutes, the status will change to Normal.

Model Deployment

Now, we can deploy the model as a real time service, click Deploy -> Real-Time Services,

You can choose CPU or GPU to deploy, here we choose CPU,

Click Next -> Submit -> Back to Real-Time Service List, it will cost 10 minutes, the status will change to Running,

Click the service name, jump to service detail web page, click Prediction -> Upload, choose an image from dishes_detect_600/test directory that has downloaded before, click Predict, then you will see the detection results that predicted by the AI model trained by yourself.

OK, we have finished all the steps of using a bulit-in algorithm to train an object detection model, congratulations!

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。