English|中文
This sample provides reference for you to learn the Ascend AI Software Stack and cannot be used for commercial purposes.
This README file provides only guidance for running the sample in command line (CLI) mode. For details about how to run the sample in MindStudio, see Running Video Samples in MindStudio.
Function: Use the GoogLeNet model to perform classification inference on input videos.
Input: source MP4 video file.
Output: inference result displayed on the Presenter Server WebUI.
Check whether the following requirements are met. If not, perform operations according to the remarks. If the CANN version is upgraded, check whether the third-party dependencies need to be reinstalled. (The third-party dependencies for 5.0.4 and later versions are different from those for earlier versions.)
Item | Requirement | Remarks |
---|---|---|
CANN version | ≥ 5.0.4 | Install the CANN by referring to Sample Deployment in the About Ascend Samples Repository. If the CANN version is earlier than the required version, switch to the samples repository specific to the CANN version. See Release Notes. |
Hardware | Atlas 200 DK/Atlas 300 (AI1s) | Currently, the Atlas 200 DK and Atlas 300 have passed the test. For details about the product description, see Hardware Platform. For other products, adaptation may be required. |
Third-party dependency | presentagent, opencv | For details, see Third-Party Dependency Installation Guide (C++ Sample). |
-
Obtain the source package.
You can download the source code in either of the following ways:
- Command line (The download takes a long time, but the procedure is simple.)
Note: To switch to another tag (for example, v0.5.0), run the following command:
# In the development environment, run the following commands as a non-root user to download the source repository: cd ${HOME} git clone https://github.com/Ascend/samples.git
git checkout v0.5.0
- Compressed package (The download takes a short time, but the procedure is complex.)
Note: If you want to download the code of another version, switch the branch of the samples repository according to the prerequisites.# 1. Click Clone or Download in the upper right corner of the samples repository and click Download ZIP. # 2. Upload the .zip package to the home directory of a common user in the development environment, for example, ${HOME}/ascend-samples-master.zip. # 3. In the development environment, run the following commands to unzip the package: cd ${HOME} unzip ascend-samples-master.zip
- Command line (The download takes a long time, but the procedure is simple.)
-
Convert the model.
Model Description How to Obtain GoogLeNet Image classification inference model. It is a GoogLeNet model based on Caffe. Download the model and weight file by referring to the links in README.md in the ATC_googlenet_caffe_AE directory of the ModelZoo repository. # To facilitate download, the commands for downloading the original model and converting the model are provided here. You can directly copy and run the commands. You can also refer to the above table to download the model from ModelZoo and manually convert it. cd ${HOME}/samples/cplusplus/level2_simple_inference/1_classification/googlenet_imagenet_video/model wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/classification/googlenet.caffemodel wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/classification/googlenet.prototxt wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/models/googlenet_imagenet_video/insert_op.cfg atc --model="./googlenet.prototxt" --weight="./googlenet.caffemodel" --framework=0 --output="googlenet" --soc_version=Ascend310 --insert_op_conf=./insert_op.cfg --input_shape="data:1,3,224,224" --input_format=NCHW
Run the following commands to execute the compilation script to start sample compilation:
cd ${HOME}/samples/cplusplus/level2_simple_inference/1_classification/googlenet_imagenet_video/scripts
bash sample_build.sh
Note: If the development environment and operating environment are set up on the same server, skip step 1 and go to step 2 directly.
-
Run the following commands to upload the googlenet_imagenet_video directory in the development environment to any directory in the operating environment, for example, /home/HwHiAiUser, and log in to the operating environment (host) as the running user (HwHiAiUser):
# In the following information, xxx.xxx.xxx.xxx is the IP address of the operating environment. The IP address of Atlas 200 DK is 192.168.1.2 when it is connected over the USB port, and that of Atlas 300 (AI1s) is the corresponding public IP address. scp -r ${HOME}/samples/cplusplus/level2_simple_inference/1_classification/googlenet_imagenet_video [email protected]:/home/HwHiAiUser ssh [email protected] cd ${HOME}/googlenet_imagenet_video/scripts
-
Execute the script to run the sample.
bash sample_run.sh
- Open the Presenter Server WebUI.
- For Atlas 200 DK
Open the URL that is displayed when Presenter Server is started. - For Atlas 300 AI accelerator card (AI1s cloud inference environment)
The following assumes that the intranet IP address of the Atlas 300 AI accelerator card (AI1s) is 192.168.0.194 and the public IP address is 124.70.8.192.
The message "Please visit http://192.168.0.194:7009 for display server" is displayed when Presenter Server is started.
Replace the intranet IP address 192.168.0.194 in the URL with the public IP address 124.70.8.192. That is, change the URL to http://124.70.8.192:7009.
Open the URL in the browser.
- For Atlas 200 DK
- Wait for Presenter Agent to transmit data to the server and click Refresh. When data arrives, the icon in the Status column for the corresponding Channel changes to green.
- Click a link in the View Name column to view the result.
For details about how to rectify the errors, see Troubleshooting. If an error is not included in Wiki, submit an issue to the samples repository.