百度智能云

All Product Document

          Intelligent Edge

          Operation Guide

          This section introduces how to distribute the BML training model to the edge node through BIE.

          Prerequisites

          • There is an available edge node test device. A 2-core 8G BCC is used as the test device in this case.
          • The test edge node is connected to the cloud by following the [Getting Started ](BIE/Getting Started/Quick Start Guide.md)tutorial.

          Introduction to BML

          BML is the full-featured Baidu AI development platform, which provides the service set of one-stop AI model construction function. It provides the machine learning and deep learning environment for users and realizes the whole life cycle service capability of AI construction from the data source management, data annotation, data set storage, data preprocessing, model training and production to model management, predictive reasoning service management, and full-service monitoring.


          ## Download Model from BML Model Repository

          Open the BML console to enter the Model Repository ->Model List, and find the sample model ve_mnist in the model list as shown in the figure below:

          image.png

          ve_mnist is a handwritten character recognition model, which can be the number 0-9. Click ve_mnist to view the model details, and click Download in the upper right corner to get the model file tf_mnist.zip as shown in the figure below:

          image.png


          ## Upload Model to Object Storage

          In this case, Minio is used as the object storage to upload the model tf_mnist.zip zip package to the model-upload directly of Minio as shown in the figure below:

          image.png

          The MD5 value of the tf_mnist.zip file is:1879eae40da840465c90afca70787885, which will be used during the creation of the model file configuration item later.


          ## Create Model File Configuration Item in BIE

          Open the BIE console to enter the "Configuration Management", click Create Configuration Item on the Configuration Itemtab, and fill in the following content in the pop-up box:

          image.png

          • name: tf-mnist-model
          • Description: Optional
          • Configuration item: Select Import File, and fill in the information of tf_mnist.zip in the object storage in the previous step.

          ## Create and Distribute AI Application

          Create application

          Open the BIE console to enter the Application Deployment, click Create Application, and fill in the application name tf-mnist-app. The description can be empty as shown in the figure below:

          image.png

          Then, click Next to enter the Service Configuration, where you may not make any modification. Click Next to enter the target node, where you may not make any modification, and click Create directly. In this way, an edge application is created successfully.

          Add Service

          Open the tf-mnist-app application on the Application Deployment list interface, click "Add Service", and fill in the service information in the pop-up box. which are as shown below:

          image.png

          image.png

          • Basic information

            • Service name: mnist-prediction
            • Service image address: hub.baidubce.com/aiot/tensorflow-serving: 1.15-gpu-4.2
          • Volume configuration

            • Volume name: tf-minist-model
            • Type: Configuration item
            • Parameter: Select the AI model configuration item tf-minist-model created previously from the drop-down box.
            • Container directory: /home/bml/model, you can select any directory. However, it shall be consistent with MODEL_PATH in the environment variable.
            • Read/write permission: Read/write
          • Port Mapping

            • Host port: 8010
            • Container port: 8010
            • Protocol: TCP
          • Environment variable

            • MAX_BATCH_SIZE: 1000
            • MODEL_SOURCE_TYPE: local
            • SERVING_CONSTRANT: predict
            • BATCH_TIMEOUT_MICROS: 0
            • MAX_ENQUEUED_BATCHES: 10
            • NVIDIA_VISIBLE_DEVICES: none
            • MODEL_PATH: /home/bml/model
            • MODEL_TYPE: TFSERVING
            • MODEL_NAME: tf-serving
            • MODEL_PROTOCOL: pb/pbtxt
            • OUTPUT_NODES:
            • LANG: en_US.UTF-8
            • INPUT_NODES:
            • DEPLOY_ENV: private
          • Other configuration

            • Use the default item.

          Set Target Node

          Set the target node on the tf-mnist-app Application Details interface as shown in the figure below, and match the edge node bcc-node through the tag. On completion of the tag setting, the application is deployed automatically. On completion of deployment, the deployment status is Deployed.

          image.png

          Verify Edge AI Service

          Prepare test data

          Log in to the edge node through SSH, create a test.json file, and fill in the test data in the test file, which can be completed with the following command.

          # Create test.json
          sudo vim test.json
          # Enter the following
          {"instances": [{"images": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3294117748737335, 0.7254902124404907, 0.6235294342041016, 0.5921568870544434, 0.2352941334247589, 0.1411764770746231, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8705883026123047, 0.9960784912109375, 0.9960784912109375, 0.9960784912109375, 0.9960784912109375, 0.9450981020927429, 0.7764706611633301, 0.7764706611633301, 0.7764706611633301, 0.7764706611633301, 0.7764706611633301, 0.7764706611633301, 0.7764706611633301, 0.7764706611633301, 0.6666666865348816, 0.2039215862751007, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.26274511218070984, 0.44705885648727417, 0.2823529541492462, 0.44705885648727417, 0.6392157077789307, 0.8901961445808411, 0.9960784912109375, 0.8823530077934265, 0.9960784912109375, 0.9960784912109375, 0.9960784912109375, 0.9803922176361084, 0.8980392813682556, 0.9960784912109375, 0.9960784912109375, 0.5490196347236633, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06666667014360428, 0.25882354378700256, 0.05490196496248245, 0.26274511218070984, 0.26274511218070984, 0.26274511218070984, 0.23137256503105164, 0.08235294371843338, 0.9254902601242065, 0.9960784912109375, 0.41568630933761597, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.32549020648002625, 0.9921569228172302, 0.8196079134941101, 0.07058823853731155, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.08627451211214066, 0.9137255549430847, 1.0, 0.32549020648002625, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5058823823928833, 0.9960784912109375, 0.9333333969116211, 0.1725490242242813, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.23137256503105164, 0.9764706492424011, 0.9960784912109375, 0.24313727021217346, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5215686559677124, 0.9960784912109375, 0.7333333492279053, 0.019607843831181526, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03529411926865578, 0.803921639919281, 0.9725490808486938, 0.22745099663734436, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4941176772117615, 0.9960784912109375, 0.7137255072593689, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.29411765933036804, 0.9843137860298157, 0.9411765336990356, 0.22352942824363708, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.07450980693101883, 0.8666667342185974, 0.9960784912109375, 0.6509804129600525, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.011764707043766975, 0.7960785031318665, 0.9960784912109375, 0.8588235974311829, 0.13725490868091583, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.14901961386203766, 0.9960784912109375, 0.9960784912109375, 0.3019607961177826, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.12156863510608673, 0.8784314393997192, 0.9960784912109375, 0.45098042488098145, 0.003921568859368563, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5215686559677124, 0.9960784912109375, 0.9960784912109375, 0.2039215862751007, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2392157018184662, 0.9490196704864502, 0.9960784912109375, 0.9960784912109375, 0.2039215862751007, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4745098352432251, 0.9960784912109375, 0.9960784912109375, 0.8588235974311829, 0.1568627506494522, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4745098352432251, 0.9960784912109375, 0.8117647767066956, 0.07058823853731155, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}], "signature_name": "predict_images"}

          Call AI service

          After the test data is prepared, we need to find the external IP address of the AI service, and then call the HTTP service through the curl command which can be completed with the following command.

          kubectl get pod -A -owide
          curl 10.42.0.21:8010/v1/models/tf-serving:predict -X POST -d@test.json
          # Because the port mapping was done earlier, you can also directly use the address 127.0.0.1 to access the service
          curl 127.0.0.1:8010/v1/models/tf-serving:predict -X POST -d@test.json

          The final execution results are shown in the figure below:

          image.png

          As shown in the figure above, the probability of test data 0-9 is given. The probability of test data 7 is 0.99597472, and the secondary treatment can be carried out for the above output results, and then the result 7 is returned directly.

          For the specific mnist data, refer to the Official Website.

          Previous
          OPCUA Usage
          Next
          video-infer Realizes AI Inference of Edge Videos