Service Running (C++)

Running the Inference Service

When the operating environment is Atlas 500 AI edge station, pay attention to the following:

  • The G++ compiler is missing. Run the sample by referring to Service Running (Python).
  • It can only be used as the operating environment. The EulerOS, driver, and firmware are preinstalled before delivery. If no Arm-based device is available, you can cross-compile SDK applications on Ubuntu 18.04 x86_64, and then deploy the compiled applications on the Atlas 500 AI edge station. For details, see Cross Compilation Description.

Before running this program, you need to download an image containing animals, name the image test.jpg, and save it to the C++ directory of the sample project.

  1. Obtain the model.
    1. Download the .pb files of the YOLOv3 and ResNet-50 models from the Ascend developer community. For details, see Table 1.
      Table 1 Model obtaining

      Model Name

      How to Obtain

      YOLOv3

      Link

      ResNet-50

      Link

    2. Save the .pb file of the model.
      • Save the .pb file of the obtained YOLOv3 model to the following path:

        SDK installation root directory/samples/mxManufacture/models/yolov3

      • Save the .pb file of the obtained ResNet-50 model to the following path:

        SDK installation root directory/samples/mxManufacture/models/resnet50

    3. Convert the models. For details about how to convert other models, see Model Conversion.
      1. Go to the path where the .pb file of the YOLOv3 model is stored and run the following commands to convert the YOLOv3 model:
        cd SDK installation root directory/samples/mxManufacture/models/yolov3
        atc --model=./yolov3_tf.pb \
        --framework=3 \
        --output=./yolov3_tf_bs1_fp16 \
        --soc_version=Ascend310 \
        --output_type=FP32 \
        --insert_op_conf=./aipp_yolov3_416_416.aippconfig \
        --input_shape="input:1,416,416,3" \
        --out_nodes="yolov3/yolov3_head/Conv_6/BiasAdd:0;yolov3/yolov3_head/Conv_14/BiasAdd:0;yolov3/yolov3_head/Conv_22/BiasAdd:0"

        out_nodes specifies the sequence of output nodes and needs to adapt to the post-processing of the model.

      2. Go to the path where the .pb file of the ResNet-50 model is stored and run the following commands to convert the ResNet-50 model:
        cd SDK installation root directory/samples/mxManufacture/models/resnet50
        atc --model=./resnet50_tensorflow_1.7.pb \
        --framework=3 \
        --output=resnet50_aipp_tf \
        --output_type=FP32 \
        --soc_version=Ascend310 \
        --input_format=NHWC \
        --input_shape="Placeholder:1,224,224,3" \
        --insert_op_conf=./aipp_resnet50_224_224.aippconfig
  2. Modify the pipeline configuration file.

    Run the following command to go to the directory of the configuration file. Replace {sdk_install_path} with the installation directory of the SDK development kit.

    cd SDK installation root directory/samples/mxManufacture/pipeline

    If you need to modify the properties of service stream elements in the configuration file or create a service stream, you can refer to the sample configuration file Sample.pipeline in the current path and Process Orchestration.

  3. Manage log configurations.
    1. For logs, the program searches for the config/logging.conf file in the current directory first. (For details, see Log Configuration File).
    2. If the config/logging.conf file does not exist in the current directory, the program searches for it in the directory specified by MX_SDK_HOME.
    3. If the config/logging.conf file does not exist in the current directory or in the MX_SDK_HOME directory, the default values are used to print logs, and the generated logs are stored in the default path /tmp/log/mindx-sdk.
  4. Perform inference.

    Go to the {sdk_install_path}/samples/mxManufacture/C++ directory. Run the script according to the readme file in the C++ directory, which contains the sample code. (run.sh is the script that implements code compilation and running.)

Viewing the Inference Result

View the result in the printed information. An example of returned results is as follows:

Figure 1 Returned result