Performing Inference on an AscendCL Application Project
Data Preparation
- Obtain the input images of this sample from the following links and perform operations based on the actual application scenario.
- Upload the obtained file to the project_directory/data directory in the development environment as the running user.
- Log in to the development environment as the running user.
- Switch to the project_directory/data directory and run the transferPic.py script.Convert the .jpg files to the .bin files and resize the images from 1024 x 683 to 224 x 224. Find the generated two .bin files in the project_directory/data directory.
python3 ../script/transferPic.py
If you get the following error message during script execution, the Pillow library is missing. Run the pip3 install Pillow --user command to install the Pillow library.
ModuleNotFoundError: No module named 'PIL'
Application Development
After an application project is created, in the src directory you can find the .cpp template code of the application for system initialization, model execution, model uninstallation, resource destruction, and more. To use the code, you only need to make the following modifications to sample_process.cpp based on the model file name, image name, and path (relative path only).
Change the image file names and paths, and the OM model path after offline conversion as needed.
In the template code, APIs prefixed with acl are available to users. For details about the APIs, see "AscendCL API Reference" in the AscendCL Application Software Development Guide (C&C++).
Application Project Build and Run
- Perform build configuration.On the MindStudio project page, choose from menu bar to enter the build configuration page.
- Set build parameters and click
to add configurations.The configuration option marked with (default) in the list is the default one. To switch the default option to a custom option, select the custom option and click
.Figure 2 Build configuration
- Click OK to save the build project.
- Set build parameters and click
- On the MindStudio project page, choose from the top menu bar to use the default configurations for incremental build.
If no error message is displayed during the build process and the message "Build finished" is displayed, the build is successful.
Figure 3 Example of successful build
After the build is complete, the main file is generated in the out directory of the current project directory.
- Choose from the menu bar. The run configuration page is displayed.
- Choose
> CMake Application to add and configure run parameters of the application project. Figure 4 shows a configuration example. - After the configuration is complete, click Apply to save the run configuration and click OK to close the run configuration dialog box.
- On the MindStudio project page, choose Run > Run... from the top menu bar.
In the dialog box displayed, select the created run configuration and run the application.
- If no error message is displayed and the message "** finished **" is displayed, the execution is complete.
- If an error message is displayed during application execution, check the detailed logs of the operating environment. For details, see the Log Reference.
- The default log path is $HOME/ascend/log. For details, see the "Log Files" section.
- The default log level is ERROR. For details about how to query or change the log level, see the "Log Level Setting" section.
