Model Visualization

The Model Visualizer of MindStudio allows you to view the network topology and operators of an original model (.pb, .onnx, or .prototxt) or a converted offline model (.om) in a visualized way. The following uses the .om model file as an example to describe the model visualization function.

Procedure

  1. Choose Ascend > Model Visualizer or click on the menu bar. In the dialog box displayed, select a model file to be visualized, for example, resnet50.
    • Figure 1 shows the model visualization function in a Linux environment.
      Figure 1 Selecting a model to be visualized (Linux)
    • Figure 2 shows the model visualization function in a Windows environment.
      Figure 2 Selecting a model to be visualized (Windows)

      When viewing the .prototxt model file, ensure that the .prototxt model file and the related .caffemodel weight file are in the same directory.

  2. Double-click the resnet50.om model file or click OK to open the model visualization page.
    • Figure 3 shows the layout and structure before model visualization optimization.
      Figure 3 Model visualization GUI (before optimization)
    • Figure 4 shows the layout and structure after model visualization optimization.
      Figure 4 Model visualization GUI (after optimization)
      After installing the node.js tool and dagre-d3 plugin as the root user, you can optimize the visualized model layout to make the entire network topology clearer and more organized. The installation method is as follows:
      • Install the node.js tool.
        • Ubuntu OS: apt install nodejs
        • CentOS, EulerOS, and Kylin OS:
          1. Download the software package from the official website.

            For example, download node-v8.10.0-linux-arm64.tar.gz.

          2. Decompress the package.
          3. Configure the environment variables: export NODE_HOME=<directory to which the software package is decompressed> and export PATH=<directory to which the software package is decompressed>/bin:$PATH
      • Install the dagre-d3 plugin.
        • npm install dagre-d3 -g
        • Environment variable configuration: export NODE_PATH=<software_package_installation_directory>

Description of the Model Visualization GUI

  • View the operator details.

    All operators in the model are displayed, as shown in area 1 in Figure 4. Select an operator. The operator is outlined green and all its details are displayed in area 3, including the operator name and the inputs and outputs. Click in area 2 to expand the details. Click to view the details of a specific metric. Click to collapse the details.

    Area 2 shows the general structure of the network model, including the context (outlined in blue) of the operator selected in area 3 on the network. Drop down area 1 and the blue selection box in area 2 moves downwards accordingly. Any operations to the area 1 (such as zooming in and out) will be synchronized to the blue box in area 2.

    • You can scroll the mouse wheel up or down to move the view upward or downward.
    • You can press and hold Ctrl and scroll the mouse wheel up and down to zoom in or zoom out the view.
  • View the output format and shape of an operator.

    Area 1 in Figure 4 also displays the output format and shape (for example, 1,224,224,4) of each operator on the connection lines. You can move the cursor to a shape, and the output format of the operator is shown, for example, NCHW and NC1HWC0.

  • Search for an operator.

    Enter the operator name in the text box of Find in area 4 of Figure 4. The corresponding operator is displayed in the search area below. Select an operator, which adds a green outline to the operator in area 1. The details about the operator are displayed in area 3. See Figure 5.

    Figure 5 Searching for an operator
  • Find operator details.

    Select an operator layer in area 1 and click in area 3. Information about all operators at this layer is displayed. Click in the upper part of area 3 or press Ctrl+F in this area to open the search page shown in Figure 6.

    In the Figure 6 dialog box, enter the keyword to search for in the text box, select required search options, and click Find. The matched information in the list will be highlighted. If no match is found, the message Value not found is displayed. Click Close to exit the search.

    Figure 6 Finding operator details

    The parameters are described as follows:

    • Case sensitive: If selected, the search operation follows the exact letter case of the entered keyword.
    • Wrap Search: If selected, the search operation is continued from the start of the list when the end of the list is reached, until all operators are covered.
    • Backward: If selected, the search operation is from current position to the start of the list.
  • View the model output nodes.
    During model conversion, the operators res2a_branch2a, bn2a_branch2a, scale2a_branch2a, and res2a_branch2a_relu are selected as the output nodes of the model, as shown in Figure 7. You can click the TransData operator to view the input details.
    Figure 7 Differences before and after operator selection
  • View the data types of the model output nodes.

    If the output type of a node is set by specifying the Output Nodes in the Model Information tab page in Script Conversion, you can click the NetOutput node to view the data types of the input nodes after model conversion is complete.

    If only Output Type in the Model Information tab page is set during model conversion and no node is selected as output, click the NetOutput node to view the input data type after model conversion is complete.

    If dtype is DT_FLOAT, the output data type is FP32. If dtype is DT_FLOAT16, the output data type is FP16. If dtype is DT_UINT8, the output data type is UINT8.

    Figure 8 Viewing the data types of the model output node