Selecting Data
When using the safety helmet detection workflow to train a model, you need to create a training dataset for subsequent model training.
Prerequisites
- You have created an OBS bucket and folder for storing data. The OBS bucket and ModelArts Pro are in the same region. For details, Creating a Bucket and Creating a Folder.
- You have uploaded required data to OBS. See Requirements on Datasets for requirements on data and How Do I Upload Data to OBS for guide on how to upload data to OBS.
- You have created a skill using the trainable safety helmet detection skill template on the ModelArts Pro console. For details, see Creating a Skill Using a Trainable Skill Template.
Requirements on Datasets
- Unlabeled datasets
Images must be stored in one directory, as shown in the following example.
├─dataset-import-example │ IMG_20180919_114732.jpg │ IMG_20180919_114745.jpg │ IMG_20180919_114945.jpg
- If data is imported from an OBS path, you must have the permission to read the OBS path.
- Images in JPG, JPEG, PNG, and BMP formats are supported.
- Labeled datasets
Labeled objects and their labeling files (in one-to-one relationship with the labeled objects) must be in the same directory. For example, if the name of the labeled object file is IMG_20180919_114745.jpg, the name of the labeling file must be IMG_20180919_114745.xml.
The labeling files must be in PASCAL VOC format. For details about the format, see Table 1.
Example:
├─dataset-import-example │ IMG_20180919_114732.jpg │ IMG_20180919_114732.xml │ IMG_20180919_114745.jpg │ IMG_20180919_114745.xml │ IMG_20180919_114945.jpg │ IMG_20180919_114945.xml
A labeling file example is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <annotation> <folder>NA</folder> <filename>bike_1_1593531469339.png</filename> <source> <database>Unknown</database> </source> <size> <width>554</width> <height>606</height> <depth>3</depth> </size> <segmented>0</segmented> <object> <name>Dog</name> <pose>Unspecified</pose> <truncated>0</truncated> <difficult>0</difficult> <occluded>0</occluded> <bndbox> <xmin>279</xmin> <ymin>52</ymin> <xmax>474</xmax> <ymax>278</ymax> </bndbox> </object> <object> <name>Cat</name> <pose>Unspecified</pose> <truncated>0</truncated> <difficult>0</difficult> <occluded>0</occluded> <bndbox> <xmin>279</xmin> <ymin>198</ymin> <xmax>456</xmax> <ymax>421</ymax> </bndbox> </object> </annotation>
- Images in JPG, JPEG, PNG, and BMP formats are supported. The size of a single image cannot exceed 5 MB, and the total size of all images uploaded in one attempt cannot exceed 8 MB.
Table 1 PASCAL VOC format description Parameter
Mandatory
Description
folder
Yes
Directory where the data source is located
filename
Yes
Name of the file to be labeled
size
Yes
Image pixel
- width: image width. This parameter is mandatory.
- height: image height. This parameter is mandatory.
- depth: number of image channels. This parameter is mandatory.
segmented
Yes
Segmented or not
object
Yes
Object detection information. Multiple object{} functions are generated for multiple objects.
- name: class of the labeled object. This parameter is mandatory.
- pose: shooting angle of the labeled object. This parameter is mandatory.
- truncated: whether the labeled object is truncated (0 indicates that the object is not truncated). This parameter is mandatory.
- occluded: whether the labeled object is occluded (0 indicates that the object is not occluded). This parameter is mandatory.
- difficult: whether the labeled object is difficult to identify (0 indicates that the object is easy to identify). This parameter is mandatory.
- confidence: confidence score of the labeled object. The value range is 0 to 1. This parameter is optional.
- bndbox: bounding box type. This parameter is mandatory. For details about the possible values, see Table 2.
Table 2 Description of bounding box types type
Shape
Labeling Information
point
Point
Coordinates of a point
<x>100<x>
<y>100<y>
line
Line
Coordinates of points
<x1>100<x1>
<y1>100<y1>
<x2>200<x2>
<y2>200<y2>
bndbox
Rectangle
Coordinates of the upper left and lower right points
<xmin>100<xmin>
<ymin>100<ymin>
<xmax>200<xmax>
<ymax>200<ymax>
polygon
Polygon
Coordinates of points
<x1>100<x1>
<y1>100<y1>
<x2>200<x2>
<y2>100<y2>
<x3>250<x3>
<y3>150<y3>
<x4>200<x4>
<y4>200<y4>
<x5>100<x5>
<y5>200<y5>
<x6>50<x6>
<y6>150<y6>
circle
Circle
Center coordinates and radius
<cx>100<cx>
<cy>100<cy>
<r>50<r>
- Images in JPG, JPEG, PNG, and BMP formats are supported. The size of a single image cannot exceed 5 MB, and the total size of all images uploaded in one attempt cannot exceed 8 MB.
Accessing the Application Development Page
- Method 1: Accessing the page for the first time
You can directly access the Application Development page after you create a skill using a trainable skill template following instructions in Creating a Skill Using a Trainable Skill Template.
- Method 2: Creating a skill and then accessing it
- Log in to the Huawei HiLens console. In the left navigation pane, choose .
- Click the Trainable Skills tab.
- Locate the target skill and click View in the Operation column. The Application Development page is displayed.
Creating Training Datasets
Choose Application Development > Select Data. On the page that is displayed, click Create Dataset. On the Create Dataset page that is displayed on the right, set basic information about a dataset based on its storage location and labeling information and click OK. For details, see Table 3.
| Parameter | Description |
|---|---|
| Dataset | Name of a dataset to be created |
| Description | Dataset description |
| Dataset Status | Whether the dataset is labeled. The options are Labeled and Unlabeled. For details about data formats, see Requirements on Datasets. |
| Upload From | Mode for uploading training data. Currently, data can only be uploaded to OBS. Therefore the default value is OBS. |
| Input Dataset Path | Location where training data is stored in OBS Click the text box on the right of Input Dataset Path. In the displayed dialog box, select an OBS bucket and folder, and click OK. |
| Output Dataset Path | Location where the dataset to be created is stored in OBS There is a default path for storing a dataset to be created. To modify it, click Modify on the right of Output Dataset Path. In the displayed dialog box, select an OBS bucket and folder, and click OK. |
After creating training datasets, select the training dataset required for application development.
Labeling Data
Labeled data is required during model training. For uploaded datasets, you can add or modify labels. Each label should have at least five data records.
- Viewing labeling examples: Click Labeling Example on the right of Create Dataset to view the labeling example.
- Accessing the labeling page: Click Label in the Operation column of the dataset. On the Dashboard page that is displayed, click Label in the upper right corner. On the displayed page, manually label data. For details, see Labeling Data > Object Detection.
Viewing Label Parsing
After creating and selecting a training dataset, you can view the statistical data of label samples in the Label Parsing area. The horizontal axis indicates the labels, and the vertical axis indicates the number of valid samples corresponding to the label.
Follow-up Operations
On the Application Development > Select Data page, select a training dataset, label the data that is not labeled, and click Next to go to step Train Model. For details, see Training a Model.
Last Article: Introduction to Trainable Skill Templates
Next Article: Training a Model
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.