Developers can deploy the application on the Atlas 200 DK to collect camera data in real time and apply style transfermation in the video.
Before using an open source application, ensure that(C30B891 Version):
Before running the application, obtain the source code package and configure the environment as follows.
Upload all the converted .om model files to the sample-styletransfer/script directory in the source code path in 1.
Log in to Ubuntu Server where Mind Studio is located as the Mind Studio installation user and set the environment variable DDK_HOME.
Run the following commands to add the environment variables DDK_HOME and LD_LIBRARY_PATH to the last line:
- XXX indicates the Mind Studio installation user, and /home/XXX/tools indicates the default installation path of the DDK.
- If the environment variables have been added, skip this step.
Enter :wq! to save and exit.
Run the following command for the environment variable to take effect:
Access the root directory where the style transfer application code is located as the Mind Studio installation user, for example, /home/ascend/sample-styletransfer. Here, ascend is the MindStudio installation user.
Run the deployment script to prepare the project environment, including compiling and deploying the ascenddk public library and configuring Presenter Server. The Presenter Server is used to receive the data sent by the application and display the result through the browser.
bash deploy.sh host_ip model_mode
bash deploy.sh 172.16.117.103 local
When the message Please choose one to show the presenter in browser(default: 127.0.0.1): is displayed, enter the IP address used for accessing the Presenter Server service in the browser. Generally, the IP address is the IP address for accessing the Mind Studio service.
Select the IP address used by the browser to access the Presenter Server service in Current environment valid ip list, as shown in Figure 4. Here, the default ip address (127.0.0.1) is selected.
Run the following command to start the Presenter Server program of the style transfer application in the background:
python3 presenterserver/presenter_server.py --app style_transfer &
presenter_server.py is located in the presenterserver in the current directory. You can run the python3 presenter_server.py -h or python3 presenter_server.py --help command in this directory to view the usage method of presenter_server.py.
Figure 5 shows that the presenter_server service is started successfully.
Use the URL shown in the preceding figure to log in to Presenter Server (only the Chrome browser is supported). The IP address is that entered in Figure 6 and the default port number is 7018. The following figure indicates that Presenter Server is started successfully.
The following figure shows the IP address used by the Presenter Server and Mind Studio to communicate with the Atlas 200 DK.
Run the style transfer application.
Run the following command in the sample-styletransfer directory to start the style transfer application:
bash run_styletransferapp.sh host_ip presenter_view_app_name camera_channel_name &
bash run_styletransferapp.sh 172.16.117.103 video Channel-2 &
Use the URL that is displayed when you start the Presenter Server service to log in to the Presenter Server website. For details, see 3.
Wait for Presenter Agent to transmit data to the server. Click Refresh. When there is data, the icon in the Status column for the corresponding channel changes to green, as shown in Figure 8.
- The Presenter Server of the style transfer application supports a maximum of 10 channels at the same time (each presenter_view_app_name parameter corresponds to a channel).
- Due to hardware limitations, the maximum frame rate supported by each channel is 20fps, a lower frame rate is automatically used when the network bandwidth is low.
Click video in the View Name column and view the result. One result has shown in Figure 9
Stopping the style transfer Application
The style transfer application is running continually after being executed. To stop it, perform the following operation:
Run the following command in the /home/ascend/sample-styletransfer directory as the Mind Studio installation user: (Note, here ascend is the MindStudio installation user.)
bash stop_styletransferapp.sh host_ip
host_ip: For the Atlas 200 DK developer board, this parameter indicates the IP address of the developer board. For the Atlas 300 PCIe card, this parameter indicates the IP address of the PCIe card host.
bash stop_styletransferapp.sh 172.16.117.103
Stopping the Presenter Server Service
The Presenter Server service is always in the running state after being started. To stop the Presenter Server service of the style transfer application, perform the following operations:
Run the following command to check the process of the Presenter Server service corresponding to the style transfer application as the Mind Studio installation user:
ps -ef | grep presenter | grep style_transfer
pass@ThinkCentre-M8600t-N000:~/workspace/atlas_case/sample-styletransfer$ ps -ef | grep presenter | grep style_transfer pass 7701 1615 0 14:21 pts/8 00:00:00 python3 presenterserver/presenter_server.py --app style_transfer
In the preceding information, 7701 indicates the process ID of the Presenter Server service corresponding to the style transfer application.
To stop the service, run the following command:
kill -9 7701
Download the dependent software libraries to the sample-styletransfer/script directory.
Table 2 Download the dependent software library
You can search for related packages on the Python official website https://pypi.org/ for installation. If you run the pip3 install command to download the file online, you can run the following command to specify the version to be downloaded: pip3 install tornado==5.1.0 -i Installation source of the specified library --trusted-host Host name of the installation source
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容，可点击提交进行申诉，我们将尽快为您处理。