Code Monkey home page Code Monkey logo

facedetection-persenter-qt's Introduction

EN|CN

Developers can deploy the application on the Atlas 200 DK to collect camera data in real time and predict facial information in the video.

Prerequisites

Before using an open source application, ensure that:

  • MindSpore Studio has been installed. For details, see MindSpore Studio Installation Guide.
  • The Atlas 200 DK developer board has been connected to MindSpore Studio, the cross compiler has been installed, the SD card has been prepared, and basic information has been configured. For details, see Atlas 200 DK User Guide.

Software Preparation

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

  1. Obtain the source code package.

    Download all the code in the sample-facedetection repository at https://github.com/Ascend/sample-facedetection to any directory on Ubuntu Server where MindSpore Studio is located as the MindSpore Studio installation user, for example, /home/ascend/sample-facedetection/.

  2. Log in to Ubuntu Server where MindSpore Studio is located as the MindSpore 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

    NOTE:

    • XXX indicates the MindSpore 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 face detection application code is located as the MindSpore Studio installation user, for example, /home/ascend/sample-facedetection.

  2. Run the deployment script to prepare the project environment, including compiling and deploying the ascenddk public library, downloading the network model, and configuring Presenter Server.

    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 MindSpore Studio is located is not connected to the network, use the local mode. In this case, download the network model file and the dependent common code library to the sample-facedetection/script directory by referring to the Downloading Network Model and Dependency Code Library.
      • internet: Indicates the online deployment mode. If the Ubuntu system where MindSpore Studio is located is connected to the network, use the Internet mode. In this case, download the model file and dependency code library online.

    Example command:

    bash deploy.sh 192.168.1.2 internet

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

    Figure 1 Project deployment

  3. Start Presenter Server.

    Run the following command to start the Presenter Server program of the face detection application in the background:

    python3 presenterserver/presenter_server.py --app face_detection &

    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 2 shows that the presenter_server service is started successfully.

    Figure 2 Starting the Presenter Server process

    Use the URL shown in the preceding figure to log in to Presenter Server ( only the Chrome browser is supporte ). The IP address is that entered in Figure 3 and the default port number is 7007. The following figure indicates that Presenter Server is started successfully.

    Figure 3 Home page

Running

  1. Run the face detection application.

    Run the following command in the sample-facedetection directory to start the face detection application:

    bash run_facedetectionapp.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.
    • camera_channel_name: Indicates the channel to which a camera belongs. The value can be Channel-1 or Channel-2. For details, see Common Operations > View the Channel to Which a Camera Belongs of Atlas 200 DK User Guide.

    Example command:

    bash run_facedetectionapp.sh 192.168.1.2 video Channel-1 &

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

    Figure 4 Presenter Server page

    NOTE:

    • The Presenter Server of the face detection 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 image or video in the View Name column and view the result. The confidence of the detected face is marked.

Follow-up Operations

  • Stopping the Face Detection Application

    The face detection application is running continually after being executed. To stop it, perform the following operation:

    Run the following command in the /home/ascend/sample-facedetection directory as the MindSpore Studio installation user:

    bash stop_facedetectionapp.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_facedetectionapp.sh 192.168.1.2

  • 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 face detection application, perform the following operations:

    Run the following command to check the process of the Presenter Server service corresponding to the face detection application as the MindSpore Studio installation user:

    ps -ef | grep presenter | grep face_detection

    ascend@ascend-HP-ProDesk-600-G4-PCI-MT:~/sample-facedetection$ ps -ef | grep presenter | grep face_detection
    ascend    7701  1615  0 14:21 pts/8    00:00:00 python3 presenterserver/presenter_server.py --app face_detection
    

    In the preceding information, 7701 indicates the process ID of the Presenter Server service corresponding to the face detection application.

    To stop the service, run the following command:

    kill -9 7701

Downloading Network Model and Dependency Code Library

  • Downloading network model

    The models used in the application are converted models that adapt to the Ascend 310 chipset. For details about how to download this kind of models and the original network models of face detection application, see Table 1. If you have a better model solution, you are welcome to share it at https://github.com/Ascend/models.

    Download the network models files (.om files) to the sample-facedetection/script directory.

    Table 1 Models used in face detection applications

    Model Name

    Description

    Model Download Path

    Original Network Download Address

    Network model for face detection

    (face_detection.om)

    It is a network model converted from ResNet10-SSD300 model based on Caffe.

    Download the model from the computer_vision/object_detect/face_detection directory in the https://github.com/Ascend/models/ repository.

    For the version description, see the README.md file in the current directory.

    For details, see the README.md file of the computer_vision/object_detect/face_detection directory in the https://github.com/Ascend/models/ repository.

    Precautions during model conversion:

    During the conversion, a message is displayed indicating that the conversion fails. You only need to select SSDDetectionOutput from the drop-down list box for the last layer and click Retry.

  • Download the dependent software libraries

    Download the dependent software libraries to the sample-facedetection/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://github.com/Ascend/sdk-ezdvpp

    After the download, keep the folder name ezdvppใ€‚

    Presenter Agent

    API for interacting with the Presenter Server.

    https://github.com/Ascend/sdk-presenter/tree/master/presenteragent

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

    Search for related sources and install them.

facedetection-persenter-qt's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.