【ModelArts Course3】Built-in Algorithm for Flowers Classification

举报
雨落无痕 发表于 2023/03/14 15:58:20 2023/03/14
【摘要】 Using Built-in Algorithm for Flowers Classification (Image Classification)This Experiment Describes How to Use the Flowers Dataset to Retrain a Pre-Configured Model on HUAWEI CLOUD ModelArts to Qu...

Using Built-in Algorithm for Flowers Classification (Image Classification)

This Experiment Describes How to Use the Flowers Dataset to Retrain a Pre-Configured Model on HUAWEI CLOUD ModelArts to Quickly Build a Flower Image Classification Application.

1. Prepare Data

1.1 Creating an OBS Bucket

Log in to the HUAWEI CLOUD console, move the cursor to the left pane, and choose Service List > Storage > Object Storage Service, as shown below.
image

Click Create Bucket to access the creation page.
image

Start the creation. The parameters are as follows:

  1. Region: AP-Singapore;
  2. Bucket Name: User-defined;
  3. Data Redundancy Policy: Single-AZ storage;
  4. Default Storage Class: Standard;
  5. Bucket Policy: Private;
  6. Default Encryption: Default Disable;

Click Create Now > OK. And click Bucket name > Objects > Create Folder to create a folder named dataset.
image

1.2 Downloading Datasets

The experiment prepares a dataset for classification of four categories of the flower images.
This dataset contains four categories of flower images: daisy, sunflower, rose, and dandelion, with 10 images of each category and 40 images in total.You can download and unzip the dataset: flowers_40.

Now, you need to upload the dataset to the decompressed folder created in the OBS bucket in the previous step.
Back to the OBS page, and access the folder created in the previous step. And click Upload Object, click add file in the dialog box.
image

Select all the files in the folder, you can use CTRL + A to select all files, and then click Upload.
image

2. Training Model

Next, retrain the Build-in Image Classification-ResNet_v1_50 algorithm by using the training set to obtain a new model.

Click Subscribe. If Subscribed is displayed, click Access Console, as shown below.
image
image
And then select service region: AP-Singapore, click OK, as shown in the following figure.
image

The Algorithm Management page is displayed, you can view the subscribed algorithms in the My Subscriptions list. Click the drop-down button, select the latest version, and click Create Training Job on the right.
image

Access the training job page. Set the parameters as follows:

  1. Name: User-defined, for example, job-flowers
  2. Description: Optional
  3. Creation By: The latest version of the subscribed algorithm is selected by default
  4. Input: Click Data path on the right, select the uploaded dataset: flowers_40, and click OK
    image
  5. Output: Click the Data path on the right and create a folder in the OBS bucket created in 1.1 to store training output. You are advised to select an empty directory
    image
    image
  6. Hyperparameters: Default
  7. Resource Pool: Public resource pool
  8. Resource Type: GPU
  9. Instance Flavor: GPU: 1*NVIDIA-V100-pcie-32gb(32GB) | CPU: 8 vCPUs 64GB 780GB
  10. Compute Nodes: 1
    Retain the default values for other parameters. Click Submit. After confirming the parameters, click OK. The system automatically returns to the ModelArts-training job list. In the Training Job list, click the job name to access the training job details page.
    image

On the left of the training job details page, you can view basic information about the training job and algorithm configuration. On the right of the training job details page, you can view the system logs of the training job. The training log window provides the log preview, log download, and keyword search capabilities. and resource usage.
image

3. Deployment Model

After training model is completed, you can create an AI application and deploy the model as a real-time prediction service. The procedure is as follows:

3.1 Creating an AI Application

Click Create AI Application in the upper right corner. The Create AI Application page is displayed.
image
Set the parameters as follows:

  1. Name: model-flowers;
  2. Version: Default;
  3. Meta Model Source: Select from Training, and then select the model trained in step 2;
  4. AI Engine: Default;
  5. Deployment type: Real-Time Service;
    Retain the default values for other parameters. After confirming the parameters, click Create Now to complete the model creation.
    image

Return to the AI application list. If the AI application status is Normal, the AI application is successfully created.
Note: Importing a model takes about 3 minutes.
image

3.2 Deploying Real-Time Services

Click the drop-down button next to the created AI application name, click Deploy in the Operation column, and select Real-Time Services in the deployment menu bar. Alternatively, click the AI application name to access the model details page, click Deploy in the upper right corner of the page, and choose Real-Time Services from the deployment menu.
image

Set the parameters as follows:

  1. Name: service-flowers;
  2. Auto stop: Enable, 1 hour later;
  3. Description: User-defined
  4. Resource pool: Public Resource Pool
  5. AI Application and Configuration: AI Application Source from My AI Applications; AI Application and Version- Default Auto-Filled ; Specifications- CPU: 2 vCPUs 8GB
    image

After the parameters are set, click Next and click Submit as prompted to complete the deployment of the real-time service. You can access the Real-Time Service List page and wait until the service deployment is complete. When the service status changes to Running, the service deployment is successful.

Note: The deployment model is the imported model. After the deployment is created, wait for about 2 minutes for the deployment to be successful. If the deployment service status is Running, proceed to the next step.

4. Initiate a Prediction Request

You can download test image. And click the name of the real-time service that has been deployed (completed deployment) to access the service details page. Click Prediction tab to perform real-time prediction, as shown in the following figure.
Operation: Click Upload on the left, select the downloaded image to be predicted, and click Predict.
image

The returned values are shown in the following figure.
image

The prediction result shows that the matching degree of the selected image with the four types of flowers is:
dandelion: 1.000 (100% matching degree: 0.000)
daisy: 0.000 (0% matching degree: 0%)
sunflower: 0.000 (0% matching degree: 0%)
rose: 0.000 (0% matching degree: 0%)

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

评论(0

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

全部回复

上滑加载中

设置昵称

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

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

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