1 Star 0 Fork 1

AtlasCase / sample-styletransfer

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

EN|CN

style transfer

Developers can deploy the application on the Atlas 200 DK to collect camera data in real time and apply style transfermation in the video.

Prerequisites

Before using an open source application, ensure that(C30B891 Version):

  • Mind Studio has been installed. You can also refer to the website link.
  • The Atlas 200 DK developer board has been connected to Mind Studio, the cross compiler has been installed, the SD card has been prepared, and basic information has been configured.

Software Preparation

Before running the application, obtain the source code package and configure the environment as follows.

  1. Obtain the source code and model package.

    1. Download all the code in the sample-styletransfer repository at https://gitee.com/AtlasCase/sample-styletransfer to any directory on Ubuntu Server where Mind Studio is located as the Mind Studio installation user, for example, /home/ascend/sample-styletransfer/.
    2. You will be easy note that four prepared style transfer offline models with the .om suffix are in the sample-styletransfer/script directory. They respectively stand for candy/starrynight/picasso/worksoldier style.
  2. Upload all the converted .om model files to the sample-styletransfer/script directory in the source code path in 1.

  3. Log in to Ubuntu Server where Mind Studio is located as the Mind Studio installation user and set the environment variable DDK_HOME.

    vim ~/.bashrc

    Run the following commands to add the environment variables DDK_HOME and LD_LIBRARY_PATH to the last line:

    export DDK_HOME=/home/XXX/tools/che/ddk/ddk

    export LD_LIBRARY_PATH=$DDK_HOME/uihost/lib

    export PATH=$DDK_HOME/uihost/bin:$PATH

    NOTE:

    • 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:

    source ~/.bashrc

Deployment

  1. 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.

  2. 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

    • host_ip: For the Atlas 200 DK developer board, this parameter indicates the IP address of the developer board.
    • model_mode indicates the deployment mode of the model file. The default setting is internet.
      • local: If the Ubuntu system where Mind Studio is located is not connected to the network, use the local mode. In this case, download the dependent common code library to the sample-styletransfer/script directory by referring to Downloading Dependent Code Library.
      • internet: Indicates the online deployment mode. If the Ubuntu system where Mind Studio is located is connected to the network, use the Internet mode. In this case, download the dependent code library online.

    Example command:

    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.

    Figure 4 Project deployment

  3. Start Presenter Server.

    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 &

    NOTE:
    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.

    Figure 5 Starting the Presenter Server process

    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.

    Figure 6 Home page

    The following figure shows the IP address used by the Presenter Server and Mind Studio to communicate with the Atlas 200 DK.

    Figure 7 Example IP Address

    Where:

    • The IP address of the Atlas 200 DK developer board is 192.168.1.2 (connected in USB mode).
    • The IP address used by the Presenter Server to communicate with the Atlas 200 DK is in the same network segment as the IP address of the Atlas 200 DK on the UI Host server. For example: 192.168.1.223.
    • The following is an example of accessing the IP address of the Presenter Server using a browser: 10.10.0.1, because the Presenter Server and Mind Studio are deployed on the same server, the IP address is also the IP address for accessing the Mind Studio through the browser.

Running

  1. 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 &

    • host_ip: For the Atlas 200 DK developer board, this parameter indicates the IP address of the developer board.
    • presenter_view_app_name: Indicates View Name displayed on the Presenter Server page, which is user-defined. The value of this parameter must be unique on the Presenter Server page, which contains only case-senstive leters, digits, and underscores(_). The number of characters should be 3-20.
    • camera_channel_name: Indicates the channel to which a camera belongs. The value can be Channel-1 or Channel-2. For details, see View the Channel to Which a Camera Belongs in Atlas 200 DK User Guide.

    Example command:

    bash run_styletransferapp.sh 172.16.117.103 video Channel-2 &

  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.

    Figure 8 Presenter Server page

    NOTE:

    • 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.
  3. Click video in the View Name column and view the result. One result has shown in Figure 9

    Figure 9 UI result page

Follow-up Operations

  • 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.

    Example command:

    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

Downloading Dependent Code Library

Download the dependent software libraries to the sample-styletransfer/script directory.

Table 2 Download the dependent software library

Module Name

Module Description

Download Address

EZDVPP

Encapsulates the DVPP interface and provides image and video processing capabilities, such as color gamut conversion and image / video conversion

https://gitee.com/Atlas200DK/sdk-ezdvpp

After the download, keep the folder name ezdvpp.

Presenter Agent

API for interacting with the Presenter Server.

https://gitee.com/Atlas200DK/sdk-presenter/tree/master

Obtain the presenteragent folder in this path, after the download, keep the folder name presenteragent.

tornado (5.1.0)

protobuf (3.5.1)

numpy (1.14.2)

Python libraries that Presenter Server depends on.

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

Comments ( 0 )

Sign in for post a comment

About

开发者可以将本application部署至Atlas 200DK上实现对摄像头区域内的实时画面进行风格化处理的功能 spread retract
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
1
https://gitee.com/AtlasCase/sample-styletransfer.git
git@gitee.com:AtlasCase/sample-styletransfer.git
AtlasCase
sample-styletransfer
sample-styletransfer
master

Search

152606 8668e384 1899542 133635 2cd7d36e 1899542