Updated on 2023-03-27 GMT+08:00

Creating a Skill Using an Empty Template

This topic describes how to use an empty template to create a skill. If you choose to use an empty template, you need to prepare the algorithm model and logic code in advance.

Context

  • Developing skills on the Huawei HiLens console may occupy OBS resources and incur fees. For details about OBS pricing, see Product Pricing Details.
  • The algorithm model must be in .om format and meet the requirements of Huawei HiLens. For details, see Developing an Algorithm Model.
  • Logic code can be handled (stored) in either of the following ways: Online Compilation and Upload From OBS.
    • If your code logic is simple, you are advised to compile the code online.
    • If your code structure is complex, you are advised to develop the code in a local integrated development environment (IDE) and upload it in .zip or .tar.gz format from OBS. For details about how to use OBS to upload files, see Object Storage Service Getting Started. Uploading files to OBS is charged. For details about OBS pricing, see Product Pricing Details.
      • Before uploading a file, ensure that the OBS bucket is in the same region as Huawei HiLens.
      • If you upload code from OBS, compress all code files before uploading them. The uploaded files must be in .zip or tar.gz format, and the main file must be in the level-1 directory. As shown in the following example, the entry code (main.py) is in the level-1 directory. Other code needs to be designed as required. You can pack the model and code together to upload them.
      • The file (for example, main.py) where the entry code is located is configured through the Function Execution Entry parameter, which will be described later.

      The following is a code directory example:

      skill/
      |---main.py		#Main file. The file name is the same as the value of parameter Code Configuration of the new skill.
      |---depends/		#Optional, used to store the model file.
      |---workspace/		#Workspace, used to store data generated by the skill.
      	|---data/	# Used to store runtime configurations.

Prerequisites

  • Ensure that your account is not in arrears. Developing skills on the Huawei HiLens console may occupy OBS resources and incur fees. For details about OBS pricing, see Product Pricing Details.
  • The model used for creating a skill has been imported to HiLens.
  • If you select Upload From OBS, upload the logic code to your OBS bucket in advance.

1. Starting to Create a Skill

  1. Log in to the Huawei HiLens console. In the navigation pane, choose Skill Development > Skills.
  2. Click Create Skill in the upper right corner. The Create Skill page is displayed.
    Figure 1 Creating a skill

2. Filling In Basic Information

On the Create Skill page, select Create from Scratch for Skill Templates and fill in the basic information. Table 1 describes related parameters.

Figure 2 Filling in basic information
Table 1 Basic information

Parameter

Description

Skill Templates

Whether to use a template to develop a skill. If you select an existing template, the model and code of the template are used. That is, all parameters in the Skill Content module use the values specified by the template.

Name

Name of a skill. The name is also used as the root directory name when the skill is delivered to a device.

The name is a string of 3 to 60 characters that can contain only letters, digits, hyphens (-), and underscores (_). It must start with a letter and end with a letter or digit.

NOTE:

Skills in the skill market cannot share the same name. If you want to release a skill to the skill market, use a globally unique name to name the skill.

Skill Version

Skill version. The version number is in the format of A.A.A, where A is a natural number consisting of a maximum of three digits, for example, 1.0.0.

If A contains more than one digit, it cannot start with 0. For example, 01.0.0 is not allowed.

Chip

Chip supported by the skill. For skills running on HiLens Kit devices, select the Ascend 310 chip.

Skill Code Value

Used for skill verification to prevent fake skills. The value must be the same as that on the initialization interface in the code. For details about the usage, see Initializing the HiLens Framework in the HiLens Developer Guide.

Applicable Scenario

Application scenario of the skill, such as sub-scenarios of Smart Campus, Smart Home, Smart In Vehicle Device, and Smart Mall and Supermarket, and Others

Icon

Icon of the skill

OS Platform

Operating system platform where the skill runs, including Linux, Android, iOS, LiteOS, and Windows. The HiLens Kit device uses the Linux distribution EulerOS developed based on CentOS. Therefore, if the skill is to run on HiLens Kit devices, select Linux.

Description

Detailed description about the skill.

You can enter a maximum of 2048 characters. Special characters ~^$%& are not allowed.

NOTE:

If messages need to be sent to users' mobile phones or email addresses, (for example, when a stranger is detected, a message needs to be sent to notify the user), you need to add "This skill supports notification messages." in the description. Specify the message to be sent in Writing the Code. For details, see the HiLens Developer Guide.

3. Setting the Skill Content

Enter the skill content based on your model and logic code. For details about the parameters, see Table 2.

Figure 3 Setting the skill content
Table 2 Skill content parameters

Parameter

Description

Skill Format

Format of the skill. The value can be Skill package or Container image.

Runtime Language

Runtime language of the logic code. Currently, the value can be Python3.7 or C/C++. If you select C/C++ for development, online code compilation is not supported. You need to develop the code offline, compile and pack the code in the Linux environment, and upload it to OBS.

Function Execution Entry

The startup of a skill uses the code execution file as the entry, which is similar to the main function of the C language. The main file must be in the level-1 directory.

  • For skills of the Skill package format, the main file must be in the root directory of the skill package. For example, a Python skill file must end with .py.
  • For skills of the Container image format, if ENTTRYPOINT is configured in dockerfile, the description can be left blank. Otherwise, the path of the execution file in the image must be entered.

The file name contains a maximum of 1024 characters. Only letters, digits, and underscores (_) are allowed. Special characters #~^ are not allowed.

Model

Core algorithms of the skill. Train the model locally or in ModelArts and import it to the HiLens platform. Click the plus sign (+). In the dialog box that is displayed, select a model in the model management list on the Huawei HiLens platform.

Code Entry Mode

Upload mode of the logic code.

NOTE:

Firmware 1.1.2 or later supports configuring Python dependencies for skills. During skill development, you can configure Python dependencies for a skill as required. For details, see How Do I Configure Python Dependencies for a Skill.

  • Online Compilation

    When you use the logic code for online skill development, a .zip package is automatically generated and uploaded to OBS. HiLens automatically creates an OBS bucket for storing skill packages. The naming rule of the bucket is <project_id>-hilens-skill. You can go to OBS, find the OBS bucket with the corresponding naming rule, and obtain the code package file edited online.

    You can create a file or folder in the editing area to edit the logic code. The created file named index.py by default. You can rename it or create a file or folder that is not in .py format as required.

  • Upload From OBS

    You can develop complex project code offline, manually generate a .zip or .tar.gz package, upload it to OBS, and select the .zip or .tar.gz package from OBS here. Before uploading the code to OBS, you can package the model together. For details about the model and code structures, see the specifications defined in Context.

  • Select Container Image

    If the skill is in the container image format, upload the image to SWR. For details, see Uploading Images Through the Docker Client.

4. (Optional) Setting Runtime Configurations

Figure 4 Runtime configuration

You need to set parameters for some running skills. For example, import facial image libraries when using facial recognition skills. If users configure runtime configurations when running a skill, HiLens will record the configurations in the code for other developers to use. You can click Add Tag on the page and enter your configuration by referring to Table 3.

You can also click Preview JSON to view the runtime configuration's format. Developers can obtain the skill configurations in JSON format through the get_skill_config interface provided by the HiLens Framework and read the field values to use the user configurations.

The runtime configurations in JSON format are as follows:
{
        //Global configuration
	"Language": "enum",
        //Channel-based video configuration
	"multi_camera": [ //The key value multi_camera is fixed, indicating channel-based camera configuration.
		{       
			"camera_names": [     //The key value camera_names is fixed, indicating the cameras included in the group configuration.
				"cameraX",
				"cameraY"
			],
			"FaceLib": {        //Configuration name
				"from": "file source", //File type value, indicating the service from which the file comes, for example, OBS.
				"path": "file path"  //File type value, indicating the file path.
			}
		}
	],
       }
Table 3 Runtime configuration parameters

Parameter

Description

Name

Configuration name. This field can be used to obtain the configuration value in the logic code. A runtime configuration refers to the content configured by users when a skill is running. For example, facial recognition skills require users to upload facial image libraries. Note that the runtime configuration is optional. If a configuration is added, the configuration Name and Description are mandatory.

Value Type

Type of the value of a configuration item.

The value can be int, float, enum, string, or file.

Constrain

Value range of the configuration. This parameter is related to the value type.

  • Numeral type (int and float): The value range is an open or closed interval. For example, [1, 100) indicates that the value is greater than or equal to 1 and less than 100.
  • string and file: You do not need to set this parameter.
  • enum: The value range is a set, for example, {a, b}.

Explanation

Describes the function of the configuration item and how to configure it. This field is important. Users can set a configuration based on the description here. Therefore, if a skill has a runtime configuration, developers must explain it clearly.

Object

A HiLens Kit device can connect to multiple external cameras (the number of cameras cannot be greater than the total number of channels supported by the skills installed on the device). Therefore, you can develop skills that support multiple video channels.

  • If you select Video, the configuration takes effect for videos of each camera on the device. For example, camera 1 and camera 2 use different facial image libraries.
  • If you select Global, all cameras on the device use the same configuration value.

6. Confirming Information and Creating the Skill

After setting the preceding parameters, you can view the parameter values on the right pane. If a parameter is incorrectly set, a red cross is displayed on the right.

Confirm the information and click OK to create the skill.

Figure 5 Confirming information and creating the skill

After the skill is created, the Skill Development > Skills page is displayed.