App Running

The sample procedure applies to the following products:

  • Atlas 200/300/500 Inference Product
  • Atlas Training Series Product

Model Conversion

  1. Log in to the development environment as the HwHiAiUser user (running user).
  2. Obtain the ATC tool and set environment variables by referring to ATC Instructions.
  3. Prepare data.

    Obtain the ResNet-50 weight file (.caffemodel) and model file (resnet50.prototxt) from the following link and upload the files to the caffe_model directory under the resnet50_imagenet_classification directory sample in the development environment as the HwHiAiUser user (running user).

    • Visit our ModelZoo repository on Gitee and find the download links in the README.md file.
    • Visit our ModelZoo repository on GitHub and find the download links in the README.md file.
  4. Convert the ResNet-50 network into an offline model (.om file) adapted to the Ascend AI Processor.

    Go to the resnet50_imagenet_classification directory and run the following command: Ascendxxx indicates the Ascend AI Processor version. Replace it with the actual one.

    atc --model=caffe_model/resnet50.prototxt --weight=caffe_model/resnet50.caffemodel --framework=0 --output=model/resnet50 --soc_version=Ascendxxx --input_format=NCHW --input_fp16_nodes=data --output_type=FP32 --out_nodes=prob:0
    • --output: The generated resnet50.om file is stored in the resnet50_imagenet_classification/model directory.
    • Before running the atc command, ensure that you have the write permission on the resnet50_imagenet_classification directory.
    • If the soc_version of the current device cannot be determined, run the npu-smi info command on the server where the NPU driver package is installed and add Ascend information before the queried Name. For example, if the value of Name is xxxyy, the actual soc_version is Ascendxxxyy.
  5. As the HwHiAiUser running user, upload the sample directory in the development environment to the operating environment.

App Running

  1. Log in to the operating environment.
  2. Prepare test data. Click the following links to download the input images of this sample and upload the images to the resnet50_imagenet_classification/data directory in the development environment as the running user. If the directory does not exist, create it.
  3. Configure the operating environment by referring to Environment Variable Configuration.
  4. Run the following command in resnet50_imagenet_classification:
    python3 ./src/acl_net.py
  5. Check the execution result. You should find the following information upon execution success:
    Using device id:0
    model path:./model/resnet50.om
    images path:./data
    init resource stage:
    model_id:1
    init resource success
    images:./data/dog1_1024_683.jpg
    data interaction from host to device
    data interaction from host to device success
    execute stage:
    execute stage success
    data interaction from device to host
    data interaction from device to host success
    ======== top5 inference results: =============
    [161]: 0.767578
    [162]: 0.154785
    [167]: 0.038513
    [163]: 0.021606
    [166]: 0.011658
    images:./data/dog2_1024_683.jpg
    data interaction from host to device
    data interaction from host to device success
    execute stage:
    execute stage success
    data interaction from device to host
    data interaction from device to host success
    ======== top5 inference results: =============
    [267]: 0.935547
    [266]: 0.041107
    [265]: 0.018829
    [219]: 0.002607
    [160]: 0.000295
    *****run finish******
    Releasing resources stage:
    Resources released successfully.